Datasheet
LogRecord Methods
The LogRecord contains a number of methods to examine and manipulate properties on a log record,
such as message origination, the log record’s level, when it was sent into the system, and any related
resource bundles.
Method Description
Level getLevel() Returns the log record’s level.
String getMessage() Returns the unformatted version of the log message, before
formatting/localization.
long getMillis() Returns the time the log record was created in milliseconds.
Object[] getParameters() Returns an array of parameters of the log record, or null if no
parameters are set.
long getSequenceNumber() Returns the sequence number of the log record. The
sequence number is assigned in the log record’s constructor
to create a unique number for each log record.
Throwable getThrown() Returns the Throwable associated with this log record, such
as the
Exception if an exception is being logged. Returns
null if no
Throwable is set.
String getLoggerName() Returns the name of the logger, which might be null if it is
the anonymous logger.
String getSourceClassName() Gets the name of the class that might have logged the mes-
sage. This information may be specified explicitly, or inferred
from the stack trace and therefore might be inaccurate.
String getSourceMethodName() Gets the name of the method that might have logged the mes-
sage. This information may be specified explicitly, or inferred
from the stack trace and therefore might be inaccurate.
int getThreadID Returns the identifier for the thread that originated the log
message. This is an ID inside the Java VM.
Setting Information about Message Origination
The following methods allow you to set origination information on the log message such as an associ-
ated exception, class and method that logged the message, and the ID of the originating thread.
Method Description
void setSourceClassName (String Sets the name of the class where the log message is
sourceClassName) originating.
void setSourceMethodName (String Sets the name of the method where the log message
sourceMethodName) is originating.
Table continued on following page
43
Chapter 1: Key Java Language Features and Libraries
05_777106 ch01.qxp 11/28/06 10:43 PM Page 43