LogRecord

public class LogRecord extends Object
implements Serializable

LogRecord objects are used to pass logging requests between the logging framework and individual log Handlers.

When a LogRecord is passed into the logging framework it logically belongs to the framework and should no longer be used or updated by the client application.

Note that if the client application has not specified an explicit source method name and source class name, then the LogRecord class will infer them automatically when they are first accessed (due to a call on getSourceMethodName or getSourceClassName) by analyzing the call stack. Therefore, if a logging Handler wants to pass off a LogRecord to another thread, or to transmit it over RMI, and if it wishes to subsequently obtain method name or class name information it should call one of getSourceClassName or getSourceMethodName to force the values to be filled in.

Serialization notes:

  • The LogRecord class is serializable.
  • Because objects in the parameters array may not be serializable, during serialization all objects in the parameters array are written as the corresponding Strings (using Object.toString).
  • The ResourceBundle is not transmitted as part of the serialized form, but the resource bundle name is, and the recipient object's readObject method will attempt to locate a suitable resource bundle.

Public Constructor Summary

LogRecord(Level level, String msg)
Construct a LogRecord with the given level and message values.

Public Method Summary

Level
getLevel()
Get the logging message level, for example Level.SEVERE.
String
getLoggerName()
Get the source Logger's name.
String
getMessage()
Get the "raw" log message, before localization or formatting.
long
getMillis()
Get event time in milliseconds since 1970.
Object[]
getParameters()
Get the parameters to the log message.
ResourceBundle
getResourceBundle()
Get the localization resource bundle

This is the ResourceBundle that should be used to localize the message string before formatting it.

String
getResourceBundleName()
Get the localization resource bundle name

This is the name for the ResourceBundle that should be used to localize the message string before formatting it.

long
getSequenceNumber()
Get the sequence number.
String
getSourceClassName()
Get the name of the class that (allegedly) issued the logging request.
String
getSourceMethodName()
Get the name of the method that (allegedly) issued the logging request.
int
getThreadID()
Get an identifier for the thread where the message originated.
Throwable
getThrown()
Get any throwable associated with the log record.
void
setLevel(Level level)
Set the logging message level, for example Level.SEVERE.
void
setLoggerName(String name)
Set the source Logger's name.
void
setMessage(String message)
Set the "raw" log message, before localization or formatting.
void
setMillis(long millis)
Set event time.
void
setParameters(Object[] parameters)
Set the parameters to the log message.
void
setResourceBundle(ResourceBundle bundle)
Set the localization resource bundle.
void
setResourceBundleName(String name)
Set the localization resource bundle name.
void
setSequenceNumber(long seq)
Set the sequence number.
void
setSourceClassName(String sourceClassName)
Set the name of the class that (allegedly) issued the logging request.
void
setSourceMethodName(String sourceMethodName)
Set the name of the method that (allegedly) issued the logging request.
void
setThreadID(int threadID)
Set an identifier for the thread where the message originated.
void
setThrown(Throwable thrown)
Set a throwable associated with the log event.

Inherited Method Summary

Public Constructors

public LogRecord (Level level, String msg)

Construct a LogRecord with the given level and message values.

The sequence property will be initialized with a new unique value. These sequence values are allocated in increasing order within a VM.

The millis property will be initialized to the current time.

The thread ID property will be initialized with a unique ID for the current thread.

All other properties will be initialized to "null".

Parameters