org.apache.log4j.lf5
public abstract class LogRecord extends Object implements Serializable
Field Summary | |
---|---|
protected String | _category |
protected LogLevel | _level |
protected String | _location |
protected String | _message |
protected long | _millis |
protected String | _ndc |
protected static long | _seqCount |
protected long | _sequenceNumber |
protected String | _thread |
protected Throwable | _thrown |
protected String | _thrownStackTrace |
Constructor Summary | |
---|---|
LogRecord() |
Method Summary | |
---|---|
String | getCategory()
Get the category asscociated with this LogRecord. |
LogLevel | getLevel()
Get the level of this LogRecord.
|
String | getLocation()
Get the location in code where this LogRecord originated.
|
String | getMessage()
Get the message asscociated with this LogRecord.
|
long | getMillis()
Get the event time of this record in milliseconds from 1970.
|
String | getNDC()
Get the NDC (nested diagnostic context) for this record.
|
protected static long | getNextId() |
long | getSequenceNumber()
Get the sequence number associated with this LogRecord. |
String | getThreadDescription()
Get the thread description asscociated with this LogRecord. |
Throwable | getThrown()
Get the Throwable associated with this LogRecord.
|
String | getThrownStackTrace()
Get the stack trace in a String-based format for the associated Throwable
of this LogRecord. |
boolean | hasThrown() |
boolean | isFatal() |
abstract boolean | isSevereLevel()
Abstract method. |
static void | resetSequenceNumber()
Resets that sequence number to 0.
|
void | setCategory(String category)
Set the category associated with this LogRecord. |
void | setLevel(LogLevel level)
Set the level of this LogRecord.
|
void | setLocation(String location)
Set the location in code where this LogRecord originated.
|
void | setMessage(String message)
Set the message associated with this LogRecord.
|
void | setMillis(long millis)
Set the event time of this record. |
void | setNDC(String ndc)
Set the NDC (nested diagnostic context) for this record.
|
void | setSequenceNumber(long number)
Set the sequence number assocsiated with this LogRecord. |
void | setThreadDescription(String threadDescription)
Set the thread description associated with this LogRecord. |
void | setThrown(Throwable thrown)
Set the Throwable associated with this LogRecord. |
void | setThrownStackTrace(String trace)
Set the ThrownStackTrace for the log record.
|
String | toString()
Return a String representation of this LogRecord. |
Returns: The category of this record.
See Also: setCategory
Returns: The string containing the location information.
Returns: The message of this record.
See Also: setMessage
Returns: The event time of this record in milliseconds from 1970.
See Also: LogRecord
Returns: The string representing the NDC.
Returns: The sequence number of this record.
See Also: LogRecord
Returns: The thread description of this record.
See Also: setThreadDescription
Returns: The LogLevel of this record.
See Also: setThrown getThrownStackTrace
Why do we need this method considering that we have the getThrown() and setThrown() methods? A Throwable object may not be serializable, however, a String representation of it is. Users of LogRecords should generally call this method over getThrown() for the reasons of serialization.
Returns: The Stack Trace for the asscoiated Throwable of this LogRecord.
Returns: true if getThrown().toString() is a non-empty string.
Returns: true if isSevereLevel() or hasThrown() returns true.
When logging messages
for a particluar class you can use its class name:
com.thoughtworks.framework.servlet.ServletServiceBroker.
Futhermore, to log a message for a particular method in a class
add the method name:
com.thoughtworks.framework.servlet.ServletServiceBroker.init().
Parameters: category The category for this record.
See Also: getCategory
Parameters: level The LogLevel for this record.
Parameters: location A string containing location information.
Parameters: message The message for this record.
See Also: getMessage
Parameters: millis The time in milliseconds from 1970.
See Also: getMillis
Parameters: ndc A string representing the NDC.
Parameters: number The sequence number.
See Also: getSequenceNumber
Parameters: threadDescription The description of the thread for this record.
See Also: getThreadDescription
Parameters: thrown A Throwable to associate with this LogRecord.
See Also: getThrown getThrownStackTrace
Parameters: trace A String to associate with this LogRecord
See Also: getThrownStackTrace