org.apache.log4j.spi
Class LoggingEvent
- Serializable
public class LoggingEvent
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 log4j
components.
This class is of concern to those wishing to extend log4j.
- Ceki Gülcü
- James P. Cakalic
String | categoryName - This field will be marked as private in future
releases.
|
String | fqnOfCategoryClass - Fully qualified name of the calling category class.
|
Priority | level - This field will be marked as private in future
releases.
|
long | timeStamp - The number of milliseconds elapsed from 1/1/1970 until logging event
was created.
|
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.
|
categoryName
public final String categoryName
This field will be marked as private in future
releases. Please do not access it directly. Use the getLoggerName()
method instead.
The category (logger) name.
fqnOfCategoryClass
public final String fqnOfCategoryClass
Fully qualified name of the calling category class.
level
public Priority level
This field will be marked as private in future
releases. Please do not access it directly. Use the getLevel()
method instead.
Level of logging event. Level cannot be serializable because it
is a flyweight. Due to its special seralization it cannot be
declared final either.
This field should not be accessed directly. You shoud use the
getLevel()
method instead.
timeStamp
public final long timeStamp
The number of milliseconds elapsed from 1/1/1970 until logging event
was created.
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 of
LoggingEvent
are filled when actually needed.
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 of
LoggingEvent
are filled when actually needed.
logger
- The logger generating this event.level
- The level of this event.message
- The message of this event.throwable
- The throwable of this event.
getLevel
public Level getLevel()
Return the level of this event. Use this form instead of directly
accessing the level
field.
getLocationInformation
public LocationInfo getLocationInformation()
Set the location information for this logging event. The collected
information is cached for future use.
getLoggerName
public String getLoggerName()
Return the name of the logger. Use this form instead of directly
accessing the categoryName
field.
getMDC
public Object getMDC(String key)
Returns the the context corresponding to the
key
parameter. If there is a local MDC copy, possibly because we are
in a logging server or running inside AsyncAppender, then we
search for the key in MDC copy, if a value is found it is
returned. Otherwise, if the search in MDC copy returns a null
result, then the current thread's
MDC
is used.
Note that
both the local MDC copy and the current
thread's MDC are searched.
getMDCCopy
public void getMDCCopy()
Obtain a copy of this thread's MDC prior to serialization or
asynchronous logging.
getMessage
public Object 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.
getNDC
public String getNDC()
This method returns the NDC for this event. It will return the
correct content even if the event was generated in a different
thread or even on a different machine. The
NDC.get()
method
should
never be called directly.
getRenderedMessage
public String getRenderedMessage()
getStartTime
public static long getStartTime()
Returns the time when the application started, in milliseconds
elapsed since 01.01.1970.
getThreadName
public String getThreadName()
getThrowableInformation
public ThrowableInformation getThrowableInformation()
Returns the throwable information contained within this
event. May be
null
if there is no such information.
Note that the
Throwable
object contained within a
ThrowableInformation
does not survive serialization.
getThrowableStrRep
public String[] getThrowableStrRep()
Return this event's throwable's string[] representaion.
Copyright 2000-2005 Apache Software Foundation.