Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.util.logging

Class LogRecord

java.lang.Object
|
+--java.util.logging.LogRecord

All Implemented Interfaces:

Serializable


public class LogRecord

extends Object

implements Serializable

A LogRecord contains the state for an individual event to be logged.

As soon as a LogRecord instance has been handed over to the logging framework, applications should not manipulate it anymore.

Author:

Constructor Summary

LogRecord(java.util.logging.Level level, java.lang.String message)

Constructs a LogRecord given a severity level and an unlocalized message text.

Method Summary

java.util.logging.LevelgetLevel()

Returns the level of the LogRecord.
java.lang.StringgetLoggerName()

Returns the name of the logger where this LogRecord has originated.
java.lang.StringgetMessage()

Returns the message for this LogRecord before any localization or parameter substitution.
longgetMillis()

Returns the time when this LogRecord was created.
java.lang.Object[]getParameters()

Returns the parameters to the log message.
java.util.ResourceBundlegetResourceBundle()

Returns the resource bundle that is used when the message of this LogRecord needs to be localized.
java.lang.StringgetResourceBundleName()

Returns the name of the resource bundle that is used when the message of this LogRecord needs to be localized.
longgetSequenceNumber()

Returns the sequence number of this LogRecord.
java.lang.StringgetSourceClassName()

Returns the name of the class where the event being logged has had its origin.
java.lang.StringgetSourceMethodName()

Returns the name of the method where the event being logged has had its origin.
intgetThreadID()

Returns an identifier for the thread in which this LogRecord was created.
java.lang.ThrowablegetThrown()

Returns the Throwable associated with this LogRecord, or null if the logged event is not related to an exception or error.
voidsetLevel(java.util.logging.Level level)

Sets the severity level of this LogRecord to a new value.
voidsetLoggerName(java.lang.String name)

Sets the name of the logger where this LogRecord has originated.
voidsetMessage(java.lang.String message)

Sets the message for this LogRecord.
voidsetMillis(long millis)

Sets the time when this LogRecord was created.
voidsetParameters(java.lang.Object[] parameters)

Sets the parameters to the log message.
voidsetResourceBundle(java.util.ResourceBundle bundle)

Sets the resource bundle that is used when the message of this LogRecord needs to be localized.
voidsetResourceBundleName(java.lang.String name)

Sets the name of the resource bundle that is used when the message of this LogRecord needs to be localized.
voidsetSequenceNumber(long seqNum)

Sets the sequence number of this LogRecord to a new value.
voidsetSourceClassName(java.lang.String sourceClassName)

Sets the name of the class where the event being logged has had its origin.
voidsetSourceMethodName(java.lang.String sourceMethodName)

Sets the name of the method where the event being logged has had its origin.
voidsetThreadID(int threadID)

Sets the identifier indicating in which thread this LogRecord was created.
voidsetThrown(java.lang.Throwable thrown)

Associates this LogRecord with an exception or error.

Constructor Details

LogRecord

public LogRecord(java.util.logging.Level level, java.lang.String message)

Constructs a LogRecord given a severity level and an unlocalized message text. In addition, the sequence number, creation time (as returned by getMillis()) and thread ID are assigned. All other properties are set to null.

Parameters:


Method Details

getLevel

public Level getLevel()

Returns the level of the LogRecord.

Applications should be aware of the possibility that the result is not necessarily one of the standard logging levels, since the logging framework allows to create custom subclasses of java.util.logging.Level. Therefore, filters should perform checks like theRecord.getLevel().intValue() == Level.INFO.intValue() instead of theRecord.getLevel() == Level.INFO.


getLoggerName

public String getLoggerName()

Returns the name of the logger where this LogRecord has originated.

Returns:


getMessage

public String getMessage()

Returns the message for this LogRecord before any localization or parameter substitution.

A Logger will try to localize the message if a resource bundle has been associated with this LogRecord. In this case, the logger will call getMessage() and use the result as the key for looking up the localized message in the bundle. If no bundle has been associated, or if the result of getMessage() is not a valid key in the bundle, the logger will use the raw message text as returned by this method.

Returns:


getMillis

public long getMillis()

Returns the time when this LogRecord was created.

Returns:


getParameters

public Object[] getParameters()

Returns the parameters to the log message.

Returns:


getResourceBundle

public ResourceBundle getResourceBundle()

Returns the resource bundle that is used when the message of this LogRecord needs to be localized.

Returns:


getResourceBundleName

public String getResourceBundleName()

Returns the name of the resource bundle that is used when the message of this LogRecord needs to be localized.

Returns:


getSequenceNumber

public long getSequenceNumber()

Returns the sequence number of this LogRecord.


getSourceClassName

public String getSourceClassName()

Returns the name of the class where the event being logged has had its origin. This information can be passed as parameter to some logging calls, and in certain cases, the logging framework tries to determine an approximation (which may or may not be accurate).

Returns:


getSourceMethodName

public String getSourceMethodName()

Returns the name of the method where the event being logged has had its origin. This information can be passed as parameter to some logging calls, and in certain cases, the logging framework tries to determine an approximation (which may or may not be accurate).

Returns:


getThreadID

public int getThreadID()

Returns an identifier for the thread in which this LogRecord was created. The identifier is not necessarily related to any thread identifiers used by the operating system.

Returns:


getThrown

public Throwable getThrown()

Returns the Throwable associated with this LogRecord, or null if the logged event is not related to an exception or error.


setLevel

public void setLevel(java.util.logging.Level level)

Sets the severity level of this LogRecord to a new value.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters:


setLoggerName

public void setLoggerName(java.lang.String name)

Sets the name of the logger where this LogRecord has originated.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters:


setMessage

public void setMessage(java.lang.String message)

Sets the message for this LogRecord.

A Logger will try to localize the message if a resource bundle has been associated with this LogRecord. In this case, the logger will call getMessage() and use the result as the key for looking up the localized message in the bundle. If no bundle has been associated, or if the result of getMessage() is not a valid key in the bundle, the logger will use the raw message text as returned by this method.

It is possible to set the message to either an empty String or null, although this does not make the the message very helpful to human users.

Parameters:


setMillis

public void setMillis(long millis)

Sets the time when this LogRecord was created.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters:


setParameters

public void setParameters(java.lang.Object[] parameters)

Sets the parameters to the log message.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters:


setResourceBundle

public void setResourceBundle(java.util.ResourceBundle bundle)

Sets the resource bundle that is used when the message of this LogRecord needs to be localized.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters:


setResourceBundleName

public void setResourceBundleName(java.lang.String name)

Sets the name of the resource bundle that is used when the message of this LogRecord needs to be localized.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters:


setSequenceNumber

public void setSequenceNumber(long seqNum)

Sets the sequence number of this LogRecord to a new value.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters:


setSourceClassName

public void setSourceClassName(java.lang.String sourceClassName)

Sets the name of the class where the event being logged has had its origin.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters:


setSourceMethodName

public void setSourceMethodName(java.lang.String sourceMethodName)

Sets the name of the method where the event being logged has had its origin.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters:


setThreadID

public void setThreadID(int threadID)

Sets the identifier indicating in which thread this LogRecord was created. The identifier is not necessarily related to any thread identifiers used by the operating system.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters:


setThrown

public void setThrown(java.lang.Throwable thrown)

Associates this LogRecord with an exception or error.

As soon as a LogRecord has been handed over to the logging framework, applications should not modify it anymore. Therefore, this method should only be called on freshly constructed LogRecords.

Parameters: