public class LoggingEvent extends Object implements Serializable
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.
Modifier and Type | Field and Description |
---|---|
String |
categoryName
Deprecated.
This field will be marked as private in future
releases. Please do not access it directly. Use the
getLoggerName() method instead. |
String |
fqnOfCategoryClass
Fully qualified name of the calling category class.
|
Priority |
level
Deprecated.
This field will be marked as private in future
releases. Please do not access it directly. Use the
getLevel() method instead. |
private LocationInfo |
locationInfo
Location information for the caller.
|
private Category |
logger
Deprecated.
This field will be marked as private or be completely
removed in future releases. Please do not use it.
|
private Hashtable |
mdcCopy
The mapped diagnostic context (MDC) of logging event.
|
private boolean |
mdcCopyLookupRequired
Have we tried to do an MDC lookup?
|
private Object |
message
The application supplied message of logging event.
|
(package private) static Hashtable |
methodCache |
private String |
ndc
The nested diagnostic context (NDC) of logging event.
|
private boolean |
ndcLookupRequired
Have we tried to do an NDC lookup?
|
(package private) static Integer[] |
PARAM_ARRAY |
private String |
renderedMessage
The application supplied message rendered through the log4j
objet rendering mechanism.
|
(package private) static long |
serialVersionUID |
private static long |
startTime |
private String |
threadName
The name of thread in which this logging event was generated.
|
private ThrowableInformation |
throwableInfo
This
variable contains information about this event's throwable
|
long |
timeStamp
The number of milliseconds elapsed from 1/1/1970 until logging event
was created.
|
(package private) static String |
TO_LEVEL |
(package private) static Class[] |
TO_LEVEL_PARAMS |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
String |
getFQNOfLoggerClass()
Get the fully qualified name of the calling logger sub-class/wrapper.
|
Level |
getLevel()
Return the level of this event.
|
LocationInfo |
getLocationInformation()
Set the location information for this logging event.
|
Category |
getLogger()
Gets the logger of the event.
|
String |
getLoggerName()
Return the name of the logger.
|
Object |
getMDC(String key)
Returns the the context corresponding to the
key
parameter. |
void |
getMDCCopy()
Obtain a copy of this thread's MDC prior to serialization or
asynchronous logging.
|
Object |
getMessage()
Return the message for this logging event.
|
String |
getNDC()
This method returns the NDC for this event.
|
Map |
getProperties()
Returns the set of properties
for the event.
|
String |
getProperty(String key)
Return a property for this event.
|
Set |
getPropertyKeySet()
Returns the set of the key values in the properties
for the event.
|
String |
getRenderedMessage() |
static long |
getStartTime()
Returns the time when the application started, in milliseconds
elapsed since 01.01.1970.
|
String |
getThreadName() |
ThrowableInformation |
getThrowableInformation()
Returns the throwable information contained within this
event.
|
String[] |
getThrowableStrRep()
Return this event's throwable's string[] representaion.
|
long |
getTimeStamp()
Getter for the event's time stamp.
|
boolean |
locationInformationExists()
Check for the existence of location information without creating it
(a byproduct of calling getLocationInformation).
|
private void |
readLevel(ObjectInputStream ois) |
private void |
readObject(ObjectInputStream ois) |
Object |
removeProperty(String propName)
This removes the specified MDC property from the event.
|
void |
setProperty(String propName,
String propValue)
Set value for MDC property.
|
private void |
writeLevel(ObjectOutputStream oos) |
private void |
writeObject(ObjectOutputStream oos) |
private static long startTime
public final transient String fqnOfCategoryClass
private transient Category logger
It is set by the LoggingEvent constructor or set by a remote entity after deserialization.
public final String categoryName
getLoggerName()
method instead.The category (logger) name.
public transient Priority level
getLevel()
method instead. This field should not be accessed directly. You shoud use the
getLevel()
method instead.
private boolean ndcLookupRequired
private boolean mdcCopyLookupRequired
private String renderedMessage
private String threadName
private ThrowableInformation throwableInfo
public final long timeStamp
private LocationInfo locationInfo
static final long serialVersionUID
static final Integer[] PARAM_ARRAY
static final String TO_LEVEL
static final Class[] TO_LEVEL_PARAMS
static final Hashtable methodCache
public LoggingEvent(String fqnOfCategoryClass, Category logger, Priority level, Object message, Throwable throwable)
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.public LoggingEvent(String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, Object message, Throwable throwable)
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.public LoggingEvent(String fqnOfCategoryClass, Category logger, long timeStamp, Level level, Object message, String threadName, ThrowableInformation throwable, String ndc, LocationInfo info, Map properties)
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 propertiespublic LocationInfo getLocationInformation()
public Level getLevel()
level
field.public String getLoggerName()
categoryName
field.public Category getLogger()
public Object getMessage()
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.
public String getNDC()
NDC.get()
method
should never be called directly.public Object getMDC(String key)
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.
public void getMDCCopy()
public String getRenderedMessage()
public static long getStartTime()
public String getThreadName()
public ThrowableInformation getThrowableInformation()
null
if there is no such information.
Note that the Throwable
object contained within a
ThrowableInformation
does not survive serialization.
public String[] getThrowableStrRep()
private void readLevel(ObjectInputStream ois) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
private void writeObject(ObjectOutputStream oos) throws IOException
IOException
private void writeLevel(ObjectOutputStream oos) throws IOException
IOException
public final void setProperty(String propName, String propValue)
propName
- propValue
- public final String getProperty(String key)
key
- property namepublic final boolean locationInformationExists()
public final long getTimeStamp()
public Set getPropertyKeySet()
public Map getProperties()
public String getFQNOfLoggerClass()
public Object removeProperty(String propName)
propName
- the property name to removeWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses