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.
- Author:
- Ceki Gülcü, Sébastien Pennec
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addKeyValuePair
(org.slf4j.event.KeyValuePair kvp) void
addMarker
(org.slf4j.Marker marker) Object[]
Get the caller information for this logging event.long
Return theInstant
corresponding to the creation of this event.List
<org.slf4j.event.KeyValuePair> A list ofKeyValuePair
objects.getLevel()
List
<org.slf4j.Marker> Since SLF4J 2.0.0, the slf4j logging API assumes the possibility of multiple Marker instances in a logging event.getMdc()
Deprecated.Replaced by [@link #getMDCPropertyMap}Returns the MDC map.int
Return the number of nanoseconds past thetimestamp in seconds
.long
The sequence number associated with this event.Returns the throwable information contained within this event.long
Return the number of elapsed milliseconds since epoch in UTC.boolean
If this event has caller data, then true is returned.void
This method should be called prior to serializing an event.void
setArgumentArray
(Object[] argArray) void
setCallerData
(StackTraceElement[] callerDataArray) void
setInstant
(Instant instant) SetInstant
corresponding to the creation of this event.void
setKeyValuePairs
(List<org.slf4j.event.KeyValuePair> kvpList) void
void
void
setLoggerContextRemoteView
(LoggerContextVO loggerContextVO) void
setLoggerName
(String loggerName) void
setMDCPropertyMap
(Map<String, String> map) Set the MDC map for this event.void
setMessage
(String message) void
setSequenceNumber
(long sn) void
setThreadName
(String threadName) void
Set this event's throwable information.void
setTimeStamp
(long timeStamp) Set the number of elapsed milliseconds since epoch in UTC.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.qos.logback.classic.spi.ILoggingEvent
getMarker
-
Field Details
-
VIRTUAL_THREAD_NAME_PREFIX
- See Also:
-
REGULAR_UNNAMED_THREAD_PREFIX
- See Also:
-
-
Constructor Details
-
LoggingEvent
public LoggingEvent() -
LoggingEvent
-
-
Method Details
-
setArgumentArray
-
getArgumentArray
- Specified by:
getArgumentArray
in interfaceILoggingEvent
-
addKeyValuePair
-
setKeyValuePairs
-
getKeyValuePairs
Description copied from interface:ILoggingEvent
A list ofKeyValuePair
objects. The returned list may be null.- Specified by:
getKeyValuePairs
in interfaceILoggingEvent
- Returns:
- may be null
-
getLevel
- Specified by:
getLevel
in interfaceILoggingEvent
-
getLoggerName
- Specified by:
getLoggerName
in interfaceILoggingEvent
-
setLoggerName
-
getThreadName
- Specified by:
getThreadName
in 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 benull
if there is no such information.- Specified by:
getThrowableProxy
in interfaceILoggingEvent
-
setThrowableProxy
Set this event's throwable information. -
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
-
setLoggerContext
-
getLoggerContextVO
- Specified by:
getLoggerContextVO
in interfaceILoggingEvent
-
setLoggerContextRemoteView
-
getMessage
- Specified by:
getMessage
in interfaceILoggingEvent
-
setMessage
-
getInstant
Return theInstant
corresponding to the creation of this event.- Specified by:
getInstant
in interfaceILoggingEvent
- Returns:
- the
Instant
the event was created. - Since:
- 1.3
-
setInstant
SetInstant
corresponding to the creation of this event. The value ofgetTimeStamp()
will be overridden as well. -
getTimeStamp
Return the number of elapsed milliseconds since epoch in UTC.- Specified by:
getTimeStamp
in interfaceILoggingEvent
- Returns:
- the number of elapsed milliseconds since epoch
-
getNanoseconds
Return the number of nanoseconds past thetimestamp in seconds
.- Specified by:
getNanoseconds
in interfaceILoggingEvent
- Returns:
- the number of elapsed nanoseconds as found in
ILoggingEvent.getInstant()
- Since:
- 1.3.0
-
setTimeStamp
Set the number of elapsed milliseconds since epoch in UTC. Setting the timestamp will override the value contained ingetInstant()
. Nanoseconds value will be computed form the provided millisecond value. -
getSequenceNumber
Description copied from interface:ILoggingEvent
The sequence number associated with this event.Sequence numbers, if present, should be increasing monotonically.
- Specified by:
getSequenceNumber
in interfaceILoggingEvent
-
setSequenceNumber
-
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:
getCallerData
in interfaceILoggingEvent
- Returns:
- the caller data associated with this event.
- See Also:
-
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
-
getMarkerList
Description copied from interface:ILoggingEvent
Since SLF4J 2.0.0, the slf4j logging API assumes the possibility of multiple Marker instances in a logging event. Consequently, ILoggingEvent needs to cater for this possibility.- Specified by:
getMarkerList
in interfaceILoggingEvent
- Returns:
- the marker list, may be null
-
addMarker
-
getContextBirthTime
-
getFormattedMessage
- Specified by:
getFormattedMessage
in interfaceILoggingEvent
-
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
Set the MDC map for this event.- Parameters:
map
-- Since:
- 1.0.8
-
getMdc
-
toString
-