Skip to content

Most visited

Recently visited

navigation
Added in API level 1

LogRecord

public class LogRecord
extends Object implements Serializable

java.lang.Object
   ↳ java.util.logging.LogRecord


A LogRecord object represents a logging request. It is passed between the logging framework and individual logging handlers. Client applications should not modify a LogRecord object that has been passed into the logging framework.

The LogRecord class will infer the source method name and source class name the first time they are accessed if the client application didn't specify them explicitly. This automatic inference is based on the analysis of the call stack and is not guaranteed to be precise. Client applications should force the initialization of these two fields by calling getSourceClassName or getSourceMethodName if they expect to use them after passing the LogRecord object to another thread or transmitting it over RMI.

Summary

Public constructors

LogRecord(Level level, String msg)

Constructs a LogRecord object using the supplied the logging level and message.

Public methods

Level getLevel()

Gets the logging level.

String getLoggerName()

Gets the name of the logger.

String getMessage()

Gets the raw message.

long getMillis()

Gets the time when this event occurred, in milliseconds since 1970.

Object[] getParameters()

Gets the parameters.

ResourceBundle getResourceBundle()

Gets the resource bundle used to localize the raw message during formatting.

String getResourceBundleName()

Gets the name of the resource bundle.

long getSequenceNumber()

Gets the sequence number.

String getSourceClassName()

Gets the name of the class that is the source of this log record.

String getSourceMethodName()

Gets the name of the method that is the source of this log record.

int getThreadID()

Gets a unique ID of the thread originating the log record.

Throwable getThrown()

Gets the Throwable object associated with this log record.

void setLevel(Level level)

Sets the logging level.

void setLoggerName(String loggerName)

Sets the name of the logger.

void setMessage(String message)

Sets the raw message.

void setMillis(long millis)

Sets the time when this event occurred, in milliseconds since 1970.

void setParameters(Object[] parameters)

Sets the parameters.

void setResourceBundle(ResourceBundle resourceBundle)

Sets the resource bundle used to localize the raw message during formatting.

void setResourceBundleName(String resourceBundleName)

Sets the name of the resource bundle.

void setSequenceNumber(long sequenceNumber)

Sets the sequence number.

void setSourceClassName(String sourceClassName)

Sets the name of the class that is the source of this log record.

void setSourceMethodName(String sourceMethodName)

Sets the name of the method that is the source of this log record.

void setThreadID(int threadID)

Sets the ID of the thread originating this log record.

void setThrown(Throwable thrown)

Sets the Throwable object associated with this log record.

Inherited methods

From class java.lang.Object

Public constructors

LogRecord

Added in API level 1
LogRecord (Level level, 
                String msg)

Constructs a LogRecord object using the supplied the logging level and message. The millis property is set to the current time. The sequence property is set to a new unique value, allocated in increasing order within the VM. The thread ID is set to a unique value for the current thread. All other properties are set to null.

Parameters
level Level: the logging level, may not be null.
msg String: the raw message.
Throws
NullPointerException if level is null.

Public methods

getLevel

Added in API level 1
Level getLevel ()

Gets the logging level.

Returns
Level the logging level.

getLoggerName

Added in API level 1
String getLoggerName ()

Gets the name of the logger.

Returns
String the logger name.

getMessage

Added in API level 1
String getMessage ()

Gets the raw message.

Returns
String the raw message, may be null.

getMillis

Added in API level 1
long getMillis ()

Gets the time when this event occurred, in milliseconds since 1970.

Returns
long the time when this event occurred, in milliseconds since 1970.

getParameters

Added in API level 1
Object[] getParameters ()

Gets the parameters.

Returns
Object[] the array of parameters or null if there are no parameters.

getResourceBundle

Added in API level 1
ResourceBundle getResourceBundle ()

Gets the resource bundle used to localize the raw message during formatting.

Returns
ResourceBundle the associated resource bundle, null if none is available or the message is not localizable.

getResourceBundleName

Added in API level 1
String getResourceBundleName ()

Gets the name of the resource bundle.

Returns
String the name of the resource bundle, null if none is available or the message is not localizable.

getSequenceNumber

Added in API level 1
long getSequenceNumber ()

Gets the sequence number.

Returns
long the sequence number.

getSourceClassName

Added in API level 1
String getSourceClassName ()

Gets the name of the class that is the source of this log record. This information can be changed, may be null and is untrusted.

Returns
String the name of the source class of this log record (possiblity null)

getSourceMethodName

Added in API level 1
String getSourceMethodName ()

Gets the name of the method that is the source of this log record.

Returns
String the name of the source method of this log record.

getThreadID

Added in API level 1
int getThreadID ()

Gets a unique ID of the thread originating the log record. Every thread becomes a different ID.

Notice : the ID doesn't necessary map the OS thread ID

Returns
int the ID of the thread originating this log record.

getThrown

Added in API level 1
Throwable getThrown ()

Gets the Throwable object associated with this log record.

Returns
Throwable the Throwable object associated with this log record.

setLevel

Added in API level 1
void setLevel (Level level)

Sets the logging level.

Parameters
level Level: the level to set.
Throws
NullPointerException if level is null.

setLoggerName

Added in API level 1
void setLoggerName (String loggerName)

Sets the name of the logger.

Parameters
loggerName String: the logger name to set.

setMessage

Added in API level 1
void setMessage (String message)

Sets the raw message. When this record is formatted by a logger that has a localization resource bundle that contains an entry for message, then the raw message is replaced with its localized version.

Parameters
message String: the raw message to set, may be null.

setMillis

Added in API level 1
void setMillis (long millis)

Sets the time when this event occurred, in milliseconds since 1970.

Parameters
millis long: the time when this event occurred, in milliseconds since 1970.

setParameters

Added in API level 1
void setParameters (Object[] parameters)

Sets the parameters.

Parameters
parameters Object: the array of parameters to set, may be null.

setResourceBundle

Added in API level 1
void setResourceBundle (ResourceBundle resourceBundle)

Sets the resource bundle used to localize the raw message during formatting.

Parameters
resourceBundle ResourceBundle: the resource bundle to set, may be null.

setResourceBundleName

Added in API level 1
void setResourceBundleName (String resourceBundleName)

Sets the name of the resource bundle.

Parameters
resourceBundleName String: the name of the resource bundle to set.

setSequenceNumber

Added in API level 1
void setSequenceNumber (long sequenceNumber)

Sets the sequence number. It is usually not necessary to call this method to change the sequence number because the number is allocated when this instance is constructed.

Parameters
sequenceNumber long: the sequence number to set.

setSourceClassName

Added in API level 1
void setSourceClassName (String sourceClassName)

Sets the name of the class that is the source of this log record.

Parameters
sourceClassName String: the name of the source class of this log record, may be null.

setSourceMethodName

Added in API level 1
void setSourceMethodName (String sourceMethodName)

Sets the name of the method that is the source of this log record.

Parameters
sourceMethodName String: the name of the source method of this log record, may be null.

setThreadID

Added in API level 1
void setThreadID (int threadID)

Sets the ID of the thread originating this log record.

Parameters
threadID int: the new ID of the thread originating this log record.

setThrown

Added in API level 1
void setThrown (Throwable thrown)

Sets the Throwable object associated with this log record.

Parameters
thrown Throwable: the new Throwable object to associate with this log record.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.