public class SentryAppender
extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
| Modifier and Type | Field and Description |
|---|---|
protected String |
dsn
DSN property of the appender.
|
protected String |
environment
Identifies the environment the application is running in.
|
protected Set<String> |
extraTags
Extras to use as tags.
|
static String |
LOGBACK_MARKER
Name of the
Event.extra property containing Maker details. |
protected ch.qos.logback.classic.Level |
minLevel
If set, only events with level = minLevel and up will be recorded.
|
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. |
| Constructor and Description |
|---|
SentryAppender()
Creates an instance of SentryAppender.
|
SentryAppender(Raven raven)
Creates an instance of SentryAppender.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
append(ch.qos.logback.classic.spi.ILoggingEvent iLoggingEvent) |
protected Event |
buildEvent(ch.qos.logback.classic.spi.ILoggingEvent iLoggingEvent)
Builds an Event based on the logging event.
|
protected SentryException |
createSentryExceptionFrom(ch.qos.logback.classic.spi.IThrowableProxy throwableProxy,
StackTraceInterface stackTrace)
Given a
IThrowableProxy and a StackTraceInterface return
a SentryException to be reported to Sentry. |
protected Deque<SentryException> |
extractExceptionQueue(ch.qos.logback.classic.spi.ILoggingEvent iLoggingEvent)
Creates a sequence of
SentryExceptions given a particular ILoggingEvent. |
protected String[] |
extractPackageSimpleClassName(String canonicalClassName)
Given a
String representing a classname, return Strings
representing the package name and the class name individually. |
protected static Event.Level |
formatLevel(ch.qos.logback.classic.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 MDC and upgrade key pair to a tag sent along with the events.
|
void |
setMinLevel(String minLevel) |
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() |
protected StackTraceElement[] |
toStackTraceElements(ch.qos.logback.classic.spi.IThrowableProxy throwableProxy)
Given a
IThrowableProxy return an array of StackTraceElements
associated with the underlying Throwable. |
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, start, toStringaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextpublic static final String LOGBACK_MARKER
Event.extra property containing Maker 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 ch.qos.logback.classic.Level minLevel
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 static List<String> formatMessageParameters(Object[] parameters)
null parameters are kept as null.
parameters - parameters provided to the logging system.protected static Event.Level formatLevel(ch.qos.logback.classic.Level level)
Level into an Event.Level.level - original level as defined in logback.protected void append(ch.qos.logback.classic.spi.ILoggingEvent iLoggingEvent)
The raven instance is started in this method instead of AppenderBase.start() in order to avoid substitute loggers
being generated during the instantiation of Raven.
More on www.slf4j.org/codes.html#substituteLogger
append in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>protected void initRaven()
protected Event buildEvent(ch.qos.logback.classic.spi.ILoggingEvent iLoggingEvent)
iLoggingEvent - Log generated.protected Deque<SentryException> extractExceptionQueue(ch.qos.logback.classic.spi.ILoggingEvent iLoggingEvent)
SentryExceptions given a particular ILoggingEvent.iLoggingEvent - Information detailing a particular logging eventDeque of SentryExceptions detailing the exception chainprotected SentryException createSentryExceptionFrom(ch.qos.logback.classic.spi.IThrowableProxy throwableProxy, StackTraceInterface stackTrace)
IThrowableProxy and a StackTraceInterface return
a SentryException to be reported to Sentry.throwableProxy - Information detailing a ThrowablestackTrace - The stacktrace associated with the Throwable.SentryException object ready to be sent to Sentry.protected String[] extractPackageSimpleClassName(String canonicalClassName)
String representing a classname, return Strings
representing the package name and the class name individually.canonicalClassName - A dotted-notation string representing a class name (eg. "java.util.Date")Strings. The first of which is the package name. The second is the class name.protected StackTraceElement[] toStackTraceElements(ch.qos.logback.classic.spi.IThrowableProxy throwableProxy)
IThrowableProxy return an array of StackTraceElements
associated with the underlying Throwable.throwableProxy - Information detailing a Throwable.StackTraceElements associated w/the underlying Throwablepublic 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 setMinLevel(String minLevel)
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 ch.qos.logback.core.spi.LifeCyclestop in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>Copyright © 2012–2017. All rights reserved.