|
Log4j 1.3alpha-8 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.log4j.spi.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.
Writers of log4j components such as appenders and receivers 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.
Moreover, in the absence of certain fields, receivers must set the
values of null fields to a default non-null value. For example, in the
absence of the locationInfo data, the locationInfo field should be
set to LocationInfo.NA_LOCATION_INFO
.
Field Summary | |
String |
categoryName
The logger name. |
String |
fqnOfCategoryClass
Fully qualified name of the calling category class. |
Priority |
level
Level of logging event. |
long |
timeStamp
The number of milliseconds elapsed from 1/1/1970 until logging event was created. |
Constructor Summary | |
LoggingEvent()
The no-argument constructor for LoggingEvent. |
|
LoggingEvent(String fqnOfCategoryClass,
Category logger,
long timeStamp,
Priority level,
Object message,
Throwable throwable)
Deprecated. Please use the no argument constructor and the setter methods instead. |
|
LoggingEvent(String fqnOfLoggerClass,
Category logger,
Priority level,
Object message,
Throwable throwable)
Instantiate a LoggingEvent from the supplied parameters. |
Method Summary | |
boolean |
equals(Object rObject)
Two events are considerd equal if they refer to the same instance, or if both their timestamps and sequence numbers match. |
String |
getFQNOfLoggerClass()
Get the fully qualified name of the calling logger sub-class/wrapper. |
Level |
getLevel()
Return the level of this event. |
LocationInfo |
getLocationInformation()
Get the location information for this logging event. |
Logger |
getLogger()
Returns the logger of this event. |
String |
getLoggerName()
Return the name of the logger. |
Object |
getMDC(String key)
Deprecated. use getProperty(String) instead. |
void |
getMDCCopy()
Deprecated. use initializeProperties(). |
Object |
getMessage()
Return the message for this logging event. |
String |
getNDC()
This method returns the NDC for this event. |
Map |
getProperties()
|
String |
getProperty(String key)
Return a property for this event. |
Set |
getPropertyKeySet()
Returns the set of of the key values in the properties for the event. |
String |
getRenderedMessage()
Returns the rendered version of the message according to the renderers registered in the logger repository. |
static long |
getSequenceCount()
|
long |
getSequenceNumber()
|
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. |
int |
hashCode()
The hashcode is computed as XOR of the lower 32 bits of sequenceNumber and bits 21 to 53 of timeStamp; |
void |
initializeProperties()
If the properties field is null, this method creates a new properties map containing a copy of MDC context and a copy of the properites in LoggerRepository generating this event. |
boolean |
locationInformationExists()
Check for the existence of location information without creating it (a byproduct of calling getLocationInformation). |
void |
prepareForDeferredProcessing()
This method should be called prior to serializing an event. |
void |
setFQNOfLoggerClass(String fqnOfLoggerClass)
Set the fully qualified name of the calling logger sub-class/wrapper. |
void |
setLevel(Level level)
Set the level of this event. |
void |
setLocationInformation(LocationInfo li)
Set the location information for this logging event. |
void |
setLogger(Logger logger)
Set the logger of this event. |
void |
setLoggerName(String loggerName)
Set the loggerName for this event. |
void |
setMessage(Object message)
Set the message for this event. |
void |
setNDC(String ndcString)
This method sets the NDC string for this event. |
void |
setProperties(Hashtable properties)
|
void |
setProperty(String key,
String value)
Set a string property using a key and a string value. |
void |
setRenderedMessage(String renderedMessage)
|
void |
setSequenceNumber(long sequenceNumber)
|
void |
setThreadName(String threadName)
|
void |
setThrowableInformation(ThrowableInformation ti)
Set this event's throwable information. |
void |
setTimeStamp(long timeStamp)
Setter for the even'ts time stamp. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public transient String fqnOfCategoryClass
Note that the getLocationInfo() method relies on this fact.
public String categoryName
public transient Priority level
This field should not be accessed directly. You shoud use the getLevel()
method instead.
public long timeStamp
Constructor Detail |
public LoggingEvent()
public LoggingEvent(String fqnOfLoggerClass, Category logger, Priority level, Object message, Throwable throwable)
Note that many of the LoggingEvent fields are initialized when actually needed. For more information please refer to the comments for the LoggingEvent class at the top of this page.
logger
- The logger of 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)
Note that many of the LoggingEvent fields are initialized lazily. For more information please refer to the comments for the LoggingEvent class at the top of this page.
fqnOfCategoryClass
- The category of this event.logger
- The loggertimeStamp
- the timestamp of this logging eventlevel
- The level of this event.message
- The message of this event.throwable
- The throwable of this event.Method Detail |
public static long getSequenceCount()
public boolean equals(Object rObject)
equals
in class Object
public int hashCode()
hashCode
in class Object
public boolean locationInformationExists()
public LocationInfo getLocationInformation()
Note that after serialisation, it is impossible to correctly extract location information. In that case null is returned.
public void setLocationInformation(LocationInfo li)
public Level getLevel()
public void setLevel(Level level)
level
- The level to set.IllegalStateException
- if the level has been already set.public Logger getLogger()
public void setLogger(Logger logger)
loggerName
for the event. The logger can be set at most once.
Moreover, if the loggerName has been already set, this method will throw
an IllegalStateException
.IllegalStateException
- public String getLoggerName()
public void setLoggerName(String loggerName) throws IllegalStateException
loggerName
- The loggerName to set.IllegalStateException
- if loggerName is already setpublic 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 void setMessage(Object message)
message
- The message to set.public String getNDC()
NDC.get()
method should never be
called directly.public void setNDC(String ndcString)
IllegalStateException
- if ndc had been already set.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 void initializeProperties()
public String getProperty(String key)
The property is searched first in the properties map specific for this event, then in the MDC, then in the logger repository containing the logger of this event.
public Set getPropertyKeySet()
public String getRenderedMessage()
public void setRenderedMessage(String renderedMessage) throws IllegalStateException
renderedMessage
- The renderedMessage to set.IllegalStateException
- if renderedMessage has been already set.public static long getStartTime()
public long getSequenceNumber()
public void setSequenceNumber(long sequenceNumber)
public String getThreadName()
public void setThreadName(String threadName) throws IllegalStateException
threadName
- The threadName to set.IllegalStateException
- If threadName has been already set.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()
public void setThrowableInformation(ThrowableInformation ti)
public Map getProperties()
public void setProperties(Hashtable properties)
properties
- The properties to set.public void setProperty(String key, String value)
public void prepareForDeferredProcessing()
public long getTimeStamp()
public void setTimeStamp(long timeStamp)
getTimeStamp()
.public String getFQNOfLoggerClass()
public void setFQNOfLoggerClass(String fqnOfLoggerClass)
fqnOfLoggerClass
-
|
Log4j 1.3alpha-8 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |