@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.
|
protected String |
environment
Identifies the environment the application is running in.
|
protected Set<String> |
extraTags
Set of tags to look for in the Thread Context Map.
|
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 String |
release
Identifies the version of the application.
|
protected String |
serverName
Server name to be sent to sentry.
|
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. |
| Modifier | Constructor and Description |
|---|---|
|
SentryAppender()
Creates an instance of SentryAppender.
|
|
SentryAppender(Raven raven)
Creates an instance of SentryAppender.
|
protected |
SentryAppender(String name,
org.apache.logging.log4j.core.Filter filter)
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 release,
String environment,
String serverName,
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 |
setEnvironment(String environment) |
void |
setExtraTags(String extraTags)
Set the mapped extras that will be used to search the Thread Context Map and upgrade key pair to
a tag sent along with the events.
|
void |
setRavenFactory(String ravenFactory) |
void |
setRelease(String release) |
void |
setServerName(String serverName) |
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, start, stop, stopequalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stoppublic 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 volatile 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.
protected String release
Might be null in which case the release information will not be sent with the event.
protected String environment
Might be null in which case the environment information will not be sent with the event.
protected String serverName
Might be null in which case the hostname is found via a reverse DNS lookup.
protected Map<String,String> tags
Might be empty in which case no tags are sent.
public SentryAppender()
public SentryAppender(Raven raven)
raven - instance of Raven to use with this appender.protected SentryAppender(String name, org.apache.logging.log4j.core.Filter filter)
name - The Appender name.filter - The Filter to associate with the Appender.@PluginFactory public static SentryAppender createAppender(@PluginAttribute(value="name") String name, @PluginAttribute(value="dsn") String dsn, @PluginAttribute(value="ravenFactory") String ravenFactory, @PluginAttribute(value="release") String release, @PluginAttribute(value="environment") String environment, @PluginAttribute(value="serverName") String serverName, @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.release - Release to be sent to Sentry.environment - Environment to be sent to Sentry.serverName - serverName to be sent to Sentry.tags - Tags to add to each event.extraTags - Tags to search through the Thread Context Map.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 setRelease(String release)
public void setEnvironment(String environment)
public void setServerName(String serverName)
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 extraTags. extraTags are separated by commas(,).public void stop()
stop in interface org.apache.logging.log4j.core.LifeCyclestop in class org.apache.logging.log4j.core.AbstractLifeCycleCopyright © 2012–2017. All rights reserved.