Package ch.qos.logback.classic.spi
Class LoggingEvent
- java.lang.Object
-
- ch.qos.logback.classic.spi.LoggingEvent
-
- All Implemented Interfaces:
ILoggingEvent
,DeferredProcessingAware
public class LoggingEvent extends java.lang.Object implements ILoggingEvent
The internal representation of logging events. When an affirmative decision is made to log then aLoggingEvent
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
Fields Modifier and Type Field Description private java.lang.Object[]
argumentArray
private java.lang.StackTraceElement[]
callerDataArray
(package private) java.lang.String
formattedMessage
(package private) java.lang.String
fqnOfLoggerClass
Fully qualified name of the calling Logger class.private Level
level
Level of logging event.private LoggerContext
loggerContext
private LoggerContextVO
loggerContextVO
private java.lang.String
loggerName
private org.slf4j.Marker
marker
private java.util.Map<java.lang.String,java.lang.String>
mdcPropertyMap
private java.lang.String
message
private java.lang.String
threadName
The name of thread in which this logging event was generated.private ThrowableProxy
throwableProxy
private long
timeStamp
The number of milliseconds elapsed from 1/1/1970 until logging event was created.
-
Constructor Summary
Constructors Constructor Description LoggingEvent()
LoggingEvent(java.lang.String fqcn, Logger logger, Level level, java.lang.String message, java.lang.Throwable throwable, java.lang.Object[] argArray)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private java.lang.Throwable
extractThrowableAnRearrangeArguments(java.lang.Object[] argArray)
java.lang.Object[]
getArgumentArray()
java.lang.StackTraceElement[]
getCallerData()
Get the caller information for this logging event.long
getContextBirthTime()
java.lang.String
getFormattedMessage()
Level
getLevel()
LoggerContextVO
getLoggerContextVO()
java.lang.String
getLoggerName()
org.slf4j.Marker
getMarker()
java.util.Map<java.lang.String,java.lang.String>
getMdc()
Deprecated.Replaced by [@link #getMDCPropertyMap}java.util.Map<java.lang.String,java.lang.String>
getMDCPropertyMap()
Returns the MDC map.java.lang.String
getMessage()
java.lang.String
getThreadName()
IThrowableProxy
getThrowableProxy()
Returns the throwable information contained within this event.long
getTimeStamp()
boolean
hasCallerData()
If this event has caller data, then true is returned.void
prepareForDeferredProcessing()
This method should be called prior to serializing an event.void
setArgumentArray(java.lang.Object[] argArray)
void
setCallerData(java.lang.StackTraceElement[] callerDataArray)
void
setLevel(Level level)
void
setLoggerContextRemoteView(LoggerContextVO loggerContextVO)
void
setLoggerName(java.lang.String loggerName)
void
setMarker(org.slf4j.Marker marker)
void
setMDCPropertyMap(java.util.Map<java.lang.String,java.lang.String> map)
Set the MDC map for this event.void
setMessage(java.lang.String message)
void
setThreadName(java.lang.String threadName)
void
setThrowableProxy(ThrowableProxy tp)
Set this event's throwable information.void
setTimeStamp(long timeStamp)
java.lang.String
toString()
private void
writeObject(java.io.ObjectOutputStream out)
LoggerEventVO instances should be used for serialization.
-
-
-
Field Detail
-
fqnOfLoggerClass
transient java.lang.String 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
private java.lang.String threadName
The name of thread in which this logging event was generated.
-
loggerName
private java.lang.String loggerName
-
loggerContext
private LoggerContext loggerContext
-
loggerContextVO
private LoggerContextVO loggerContextVO
-
level
private transient Level level
Level of logging event.This field should not be accessed directly. You should use the
getLevel()
method instead.
-
message
private java.lang.String message
-
formattedMessage
transient java.lang.String formattedMessage
-
argumentArray
private transient java.lang.Object[] argumentArray
-
throwableProxy
private ThrowableProxy throwableProxy
-
callerDataArray
private java.lang.StackTraceElement[] callerDataArray
-
marker
private org.slf4j.Marker marker
-
mdcPropertyMap
private java.util.Map<java.lang.String,java.lang.String> mdcPropertyMap
-
timeStamp
private long timeStamp
The number of milliseconds elapsed from 1/1/1970 until logging event was created.
-
-
Method Detail
-
extractThrowableAnRearrangeArguments
private java.lang.Throwable extractThrowableAnRearrangeArguments(java.lang.Object[] argArray)
-
setArgumentArray
public void setArgumentArray(java.lang.Object[] argArray)
-
getArgumentArray
public java.lang.Object[] getArgumentArray()
- Specified by:
getArgumentArray
in interfaceILoggingEvent
-
getLevel
public Level getLevel()
- Specified by:
getLevel
in interfaceILoggingEvent
-
getLoggerName
public java.lang.String getLoggerName()
- Specified by:
getLoggerName
in interfaceILoggingEvent
-
setLoggerName
public void setLoggerName(java.lang.String loggerName)
-
getThreadName
public java.lang.String getThreadName()
- Specified by:
getThreadName
in interfaceILoggingEvent
-
setThreadName
public void setThreadName(java.lang.String threadName) throws java.lang.IllegalStateException
- Parameters:
threadName
- The threadName to set.- Throws:
java.lang.IllegalStateException
- If threadName has been already set.
-
getThrowableProxy
public IThrowableProxy getThrowableProxy()
Returns the throwable information contained within this event. May benull
if there is no such information.- Specified by:
getThrowableProxy
in interfaceILoggingEvent
-
setThrowableProxy
public void setThrowableProxy(ThrowableProxy tp)
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:
prepareForDeferredProcessing
in interfaceDeferredProcessingAware
- Specified by:
prepareForDeferredProcessing
in interfaceILoggingEvent
-
getLoggerContextVO
public LoggerContextVO getLoggerContextVO()
- Specified by:
getLoggerContextVO
in interfaceILoggingEvent
-
setLoggerContextRemoteView
public void setLoggerContextRemoteView(LoggerContextVO loggerContextVO)
-
getMessage
public java.lang.String getMessage()
- Specified by:
getMessage
in interfaceILoggingEvent
-
setMessage
public void setMessage(java.lang.String message)
-
getTimeStamp
public long getTimeStamp()
- Specified by:
getTimeStamp
in interfaceILoggingEvent
-
setTimeStamp
public void setTimeStamp(long timeStamp)
-
setLevel
public void setLevel(Level level)
-
getCallerData
public java.lang.StackTraceElement[] 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:
getCallerData
in interfaceILoggingEvent
- Returns:
- the caller data associated with this event.
- See Also:
ILoggingEvent.hasCallerData()
-
hasCallerData
public boolean hasCallerData()
Description copied from interface:ILoggingEvent
If 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:
hasCallerData
in interfaceILoggingEvent
- Returns:
- whether this event has caller data
-
setCallerData
public void setCallerData(java.lang.StackTraceElement[] callerDataArray)
-
getMarker
public org.slf4j.Marker getMarker()
- Specified by:
getMarker
in interfaceILoggingEvent
-
setMarker
public void setMarker(org.slf4j.Marker marker)
-
getContextBirthTime
public long getContextBirthTime()
-
getFormattedMessage
public java.lang.String getFormattedMessage()
- Specified by:
getFormattedMessage
in interfaceILoggingEvent
-
getMDCPropertyMap
public java.util.Map<java.lang.String,java.lang.String> getMDCPropertyMap()
Description copied from interface:ILoggingEvent
Returns the MDC map. The returned value can be an empty map but not null.- Specified by:
getMDCPropertyMap
in interfaceILoggingEvent
-
setMDCPropertyMap
public void setMDCPropertyMap(java.util.Map<java.lang.String,java.lang.String> map)
Set the MDC map for this event.- Parameters:
map
-- Since:
- 1.0.8
-
getMdc
public java.util.Map<java.lang.String,java.lang.String> getMdc()
Deprecated.Replaced by [@link #getMDCPropertyMap}Synonym for [@link #getMDCPropertyMap}.- Specified by:
getMdc
in interfaceILoggingEvent
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
LoggerEventVO instances should be used for serialization. Usebuild
method to create the LoggerEventVO instance.- Throws:
java.io.IOException
- Since:
- 1.0.11
-
-