@Plugin(name="Raven",
category="Core",
elementType="appender",
printObject=true)
public class SentryAppender
extends org.apache.logging.log4j.core.appender.AbstractAppender
| Modifier and Type | Field and Description |
|---|---|
static String |
APPENDER_NAME
Default name for the appender.
|
protected String |
dsn
DSN property of the appender.
|
static String |
LOG4J_MARKER
Name of the
Event.extra property containing Marker details. |
static String |
LOG4J_NDC
Name of the
Event.extra property containing NDC details. |
protected Raven |
raven
Current instance of
Raven. |
protected String |
ravenFactory
Name of the
RavenFactory being used. |
protected Map<String,String> |
tags
Additional tags to be sent to sentry.
|
static String |
THREAD_NAME
Name of the
Event.extra property containing the Thread name. |
| Constructor and Description |
|---|
SentryAppender()
Creates an instance of SentryAppender.
|
SentryAppender(Raven raven)
Creates an instance of SentryAppender.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(org.apache.logging.log4j.core.LogEvent logEvent) |
protected Event |
buildEvent(org.apache.logging.log4j.core.LogEvent event)
Builds an Event based on the logging event.
|
static SentryAppender |
createAppender(String name,
String dsn,
String ravenFactory,
String tags,
String extraTags,
org.apache.logging.log4j.core.Filter filter)
Create a Sentry Appender.
|
protected static Event.Level |
formatLevel(org.apache.logging.log4j.Level level)
Transforms a
Level into an Event.Level. |
protected static List<String> |
formatMessageParameters(Object[] parameters)
Extracts message parameters into a List of Strings.
|
protected void |
initRaven()
Initialises the Raven instance.
|
void |
setDsn(String dsn) |
void |
setExtraTags(String extraTags)
Set the mapped extras that will be used to search MDC and upgrade key pair to a tag sent along with the events.
|
void |
setRavenFactory(String ravenFactory) |
void |
setTags(String tags)
Set the tags that should be sent along with the events.
|
void |
stop() |
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, setHandler, toStringaddFilter, getFilter, hasFilter, isFiltered, removeFilter, startequals, getState, hashCode, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStoppingpublic static final String APPENDER_NAME
public static final String LOG4J_NDC
Event.extra property containing NDC details.public static final String LOG4J_MARKER
Event.extra property containing Marker details.public static final String THREAD_NAME
Event.extra property containing the Thread name.protected Raven raven
Raven.initRaven()protected String dsn
Might be null in which case the DSN should be detected automatically.
protected String ravenFactory
RavenFactory being used.
Might be null in which case the factory should be defined automatically.
public SentryAppender()
public SentryAppender(Raven raven)
raven - instance of Raven to use with this appender.@PluginFactory public static SentryAppender createAppender(@PluginAttribute(value="name") String name, @PluginAttribute(value="dsn") String dsn, @PluginAttribute(value="ravenFactory") String ravenFactory, @PluginAttribute(value="tags") String tags, @PluginAttribute(value="extraTags") String extraTags, @PluginElement(value="filters") org.apache.logging.log4j.core.Filter filter)
name - The name of the Appender.dsn - Data Source Name to access the Sentry server.ravenFactory - Name of the factory to use to build the Raven instance.tags - Tags to add to each event.extraTags - Tags to search through the MDC.filter - The filter, if any, to use.protected static Event.Level formatLevel(org.apache.logging.log4j.Level level)
Level into an Event.Level.level - original level as defined in log4j2.protected static List<String> formatMessageParameters(Object[] parameters)
null parameters are kept as null.
parameters - parameters provided to the logging system.public void append(org.apache.logging.log4j.core.LogEvent logEvent)
The raven instance is set in this method instead of AbstractFilterable.start() in order to avoid substitute loggers
being generated during the instantiation of Raven.
logEvent - The LogEvent.protected void initRaven()
protected Event buildEvent(org.apache.logging.log4j.core.LogEvent event)
event - Log generated.public void setDsn(String dsn)
public void setRavenFactory(String ravenFactory)
public void setTags(String tags)
tags - A String of tags. key/values are separated by colon(:) and tags are separated by commas(,).public void setExtraTags(String extraTags)
extraTags - A String of mappedTags. mappedTags are separated by commas(,).public void stop()
stop in interface org.apache.logging.log4j.core.LifeCyclestop in class org.apache.logging.log4j.core.filter.AbstractFilterableCopyright © 2012–2015. All rights reserved.