Package org.apache.log4j.spi
Class LoggingEvent
java.lang.Object
org.apache.log4j.spi.LoggingEvent
- Direct Known Subclasses:
LogEventAdapter
No-op version of Log4j 1.2 LoggingEvent. This class is not directly used by Log4j 1.x clients but is used by
the Log4j 2 LogEvent adapter to be compatible with Log4j 1.x components.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal long
The number of milliseconds elapsed from 1/1/1970 until logging event was created. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance.LoggingEvent
(String fqnOfCategoryClass, Category logger, long timeStamp, Level level, Object message, String threadName, ThrowableInformation throwable, String ndc, LocationInfo info, Map properties) Create new instance.LoggingEvent
(String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, Object message, Throwable throwable) Instantiate a LoggingEvent from the supplied parameters.LoggingEvent
(String fqnOfCategoryClass, Category logger, Priority level, Object message, Throwable throwable) Instantiate a LoggingEvent from the supplied parameters. -
Method Summary
Modifier and TypeMethodDescriptiongetLevel()
Return the level of this event.Set the location information for this logging event.Gets the logger of the event.Return the name of the logger.void
Obtain a copy of this thread's MDC prior to serialization or asynchronous logging.Return the message for this logging event.getNDC()
getProperty
(String key) static long
Returns the time when the application started, in milliseconds elapsed since 01.01.1970.Returns the throwable information contained within this event.String[]
Return this event's throwable's string[] representaion.long
removeProperty
(String propName) void
setProperty
(String propName, String propValue)
-
Field Details
-
timeStamp
public final long timeStampThe number of milliseconds elapsed from 1/1/1970 until logging event was created.
-
-
Constructor Details
-
LoggingEvent
public LoggingEvent()Constructs a new instance. -
LoggingEvent
public LoggingEvent(String fqnOfCategoryClass, Category logger, long timeStamp, Level level, Object message, String threadName, ThrowableInformation throwable, String ndc, LocationInfo info, Map properties) Create new instance.- Parameters:
fqnOfCategoryClass
- Fully qualified class name of Logger implementation.logger
- The logger generating this event.timeStamp
- the timestamp of this logging eventlevel
- The level of this event.message
- The message of this event.threadName
- thread namethrowable
- The throwable of this event.ndc
- Nested diagnostic contextinfo
- Location infoproperties
- MDC properties- Since:
- 1.2.15
-
LoggingEvent
public LoggingEvent(String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, Object message, Throwable throwable) Instantiate a LoggingEvent from the supplied parameters.Except
timeStamp
all the other fields ofLoggingEvent
are filled when actually needed.- Parameters:
logger
- The logger generating this event.timeStamp
- the timestamp of this logging eventlevel
- The level of this event.message
- The message of this event.throwable
- The throwable of this event.
-
LoggingEvent
public LoggingEvent(String fqnOfCategoryClass, Category logger, Priority level, Object message, Throwable throwable) Instantiate a LoggingEvent from the supplied parameters.Except
timeStamp
all the other fields ofLoggingEvent
are filled when actually needed.- Parameters:
logger
- The logger generating this event.level
- The level of this event.message
- The message of this event.throwable
- The throwable of this event.
-
-
Method Details
-
getStartTime
public static long getStartTime()Returns the time when the application started, in milliseconds elapsed since 01.01.1970.- Returns:
- the JVM start time.
-
getFQNOfLoggerClass
-
getLevel
Return the level of this event. Use this form instead of directly accessing thelevel
field.- Returns:
- Always returns null.
-
getLocationInformation
Set the location information for this logging event. The collected information is cached for future use.- Returns:
- Always returns null.
-
getLogger
Gets the logger of the event. Use should be restricted to cloning events.- Returns:
- Always returns null.
- Since:
- 1.2.15
-
getLoggerName
Return the name of the logger. Use this form instead of directly accessing thecategoryName
field.- Returns:
- Always returns null.
-
getMDC
-
getMDCCopy
public void getMDCCopy()Obtain a copy of this thread's MDC prior to serialization or asynchronous logging. -
getMessage
Return the message for this logging event.Before serialization, the returned object is the message passed by the user to generate the logging event. After serialization, the returned value equals the String form of the message possibly after object rendering.
- Returns:
- Always returns null.
- Since:
- 1.1
-
getNDC
-
getProperties
-
getProperty
-
getPropertyKeySet
-
getRenderedMessage
-
getThreadName
-
getThrowableInformation
Returns the throwable information contained within this event. May benull
if there is no such information.Note that the
Throwable
object contained within aThrowableInformation
does not survive serialization.- Returns:
- Always returns null.
- Since:
- 1.1
-
getThrowableStrRep
Return this event's throwable's string[] representaion.- Returns:
- Always returns null.
-
getTimeStamp
public long getTimeStamp() -
removeProperty
-
setProperty
-