Package ch.qos.logback.classic.spi
Class LoggingEvent
java.lang.Object
ch.qos.logback.classic.spi.LoggingEvent
- All Implemented Interfaces:
ILoggingEvent,DeferredProcessingAware
The internal representation of logging events. When an affirmative decision
is made to log then a
LoggingEvent instance is created. This
instance is passed around to the different logback-classic components.
Writers of logback-classic components such as appenders should be aware of
that some of the LoggingEvent fields are initialized lazily. Therefore, an
appender wishing to output data to be later correctly read by a receiver,
must initialize "lazy" fields prior to writing them out. See the
prepareForDeferredProcessing() method for the exact list.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Object[]private StackTraceElement[](package private) String(package private) StringFully qualified name of the calling Logger class.private LevelLevel of logging event.private LoggerContextprivate LoggerContextVOprivate Stringprivate org.slf4j.Markerprivate Stringprivate StringThe name of thread in which this logging event was generated.private ThrowableProxyprivate longThe number of milliseconds elapsed from 1/1/1970 until logging event was created. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate ThrowableextractThrowableAnRearrangeArguments(Object[] argArray) Object[]Get the caller information for this logging event.longgetLevel()org.slf4j.MarkergetMdc()Deprecated.Replaced by [@link #getMDCPropertyMap}Returns the MDC map.Returns the throwable information contained within this event.longbooleanIf this event has caller data, then true is returned.voidThis method should be called prior to serializing an event.voidsetArgumentArray(Object[] argArray) voidsetCallerData(StackTraceElement[] callerDataArray) voidvoidsetLoggerContextRemoteView(LoggerContextVO loggerContextVO) voidsetLoggerName(String loggerName) voidsetMarker(org.slf4j.Marker marker) voidsetMDCPropertyMap(Map<String, String> map) Set the MDC map for this event.voidsetMessage(String message) voidsetThreadName(String threadName) voidSet this event's throwable information.voidsetTimeStamp(long timeStamp) toString()private voidLoggerEventVO instances should be used for serialization.
-
Field Details
-
fqnOfLoggerClass
Fully qualified name of the calling Logger class. This field does not survive serialization. Note that the getCallerInformation() method relies on this fact. -
threadName
The name of thread in which this logging event was generated. -
loggerName
-
loggerContext
-
loggerContextVO
-
level
Level of logging event.This field should not be accessed directly. You should use the
getLevel()method instead. -
message
-
formattedMessage
-
argumentArray
-
throwableProxy
-
callerDataArray
-
marker
private org.slf4j.Marker marker -
mdcPropertyMap
-
timeStamp
private long timeStampThe number of milliseconds elapsed from 1/1/1970 until logging event was created.
-
-
Constructor Details
-
LoggingEvent
public LoggingEvent() -
LoggingEvent
-
-
Method Details
-
extractThrowableAnRearrangeArguments
-
setArgumentArray
-
getArgumentArray
- Specified by:
getArgumentArrayin interfaceILoggingEvent
-
getLevel
- Specified by:
getLevelin interfaceILoggingEvent
-
getLoggerName
- Specified by:
getLoggerNamein interfaceILoggingEvent
-
setLoggerName
-
getThreadName
- Specified by:
getThreadNamein interfaceILoggingEvent
-
setThreadName
- Parameters:
threadName- The threadName to set.- Throws:
IllegalStateException- If threadName has been already set.
-
getThrowableProxy
Returns the throwable information contained within this event. May benullif there is no such information.- Specified by:
getThrowableProxyin interfaceILoggingEvent
-
setThrowableProxy
Set this event's throwable information. -
prepareForDeferredProcessing
public void prepareForDeferredProcessing()This method should be called prior to serializing an event. It should also be called when using asynchronous or deferred logging. Note that due to performance concerns, this method does NOT extract caller data. It is the responsibility of the caller to extract caller information.- Specified by:
prepareForDeferredProcessingin interfaceDeferredProcessingAware- Specified by:
prepareForDeferredProcessingin interfaceILoggingEvent
-
getLoggerContextVO
- Specified by:
getLoggerContextVOin interfaceILoggingEvent
-
setLoggerContextRemoteView
-
getMessage
- Specified by:
getMessagein interfaceILoggingEvent
-
setMessage
-
getTimeStamp
public long getTimeStamp()- Specified by:
getTimeStampin interfaceILoggingEvent
-
setTimeStamp
public void setTimeStamp(long timeStamp) -
setLevel
-
getCallerData
Get the caller information for this logging event. If caller information is null at the time of its invocation, this method extracts location information. The collected information is cached for future use.Note that after serialization it is impossible to correctly extract caller information.
- Specified by:
getCallerDatain interfaceILoggingEvent- Returns:
- the caller data associated with this event.
- See Also:
-
hasCallerData
public boolean hasCallerData()Description copied from interface:ILoggingEventIf this event has caller data, then true is returned. Otherwise the returned value is null.Logback components wishing to use caller data if available without causing it to be computed can invoke this method before invoking
ILoggingEvent.getCallerData().- Specified by:
hasCallerDatain interfaceILoggingEvent- Returns:
- whether this event has caller data
-
setCallerData
-
getMarker
public org.slf4j.Marker getMarker()- Specified by:
getMarkerin interfaceILoggingEvent
-
setMarker
public void setMarker(org.slf4j.Marker marker) -
getContextBirthTime
public long getContextBirthTime() -
getFormattedMessage
- Specified by:
getFormattedMessagein interfaceILoggingEvent
-
getMDCPropertyMap
Description copied from interface:ILoggingEventReturns the MDC map. The returned value can be an empty map but not null.- Specified by:
getMDCPropertyMapin interfaceILoggingEvent
-
setMDCPropertyMap
Set the MDC map for this event.- Parameters:
map-- Since:
- 1.0.8
-
getMdc
Deprecated.Replaced by [@link #getMDCPropertyMap}Synonym for [@link #getMDCPropertyMap}.- Specified by:
getMdcin interfaceILoggingEvent
-
toString
-
writeObject
LoggerEventVO instances should be used for serialization. Usebuildmethod to create the LoggerEventVO instance.- Throws:
IOException- Since:
- 1.0.11
-