Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.util.logging.LogRecord
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.
Constructor Summary | |
Method Summary | |
Level |
|
String |
|
String |
|
long |
|
Object[] |
|
ResourceBundle |
|
String |
|
long |
|
String |
|
String |
|
int |
|
Throwable |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public LogRecord(Level level, String message)
Constructs aLogRecord
given a severity level and an unlocalized message text. In addition, the sequence number, creation time (as returned bygetMillis()
) and thread ID are assigned. All other properties are set tonull
.
- Parameters:
level
- the severity level, for exampleLevel.WARNING
.message
- the message text (which will be used as key for looking up the localized message text if a resource bundle has been associated).
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 liketheRecord.getLevel().intValue() == Level.INFO.intValue()
instead oftheRecord.getLevel() == Level.INFO
.
public String getLoggerName()
Returns the name of the logger where thisLogRecord
has originated.
- Returns:
- the name of the source
Logger
, ornull
if thisLogRecord
does not originate from aLogger
.
public String getMessage()
Returns the message for thisLogRecord
before any localization or parameter substitution.A
Logger
will try to localize the message if a resource bundle has been associated with thisLogRecord
. In this case, the logger will callgetMessage()
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 ofgetMessage()
is not a valid key in the bundle, the logger will use the raw message text as returned by this method.
- Returns:
- the message text, or
null
if there is no message text.
public long getMillis()
Returns the time when thisLogRecord
was created.
- Returns:
- the time of creation in milliseconds since the beginning of January 1, 1970.
public Object[] getParameters()
Returns the parameters to the log message.
- Returns:
- the parameters to the message, or
null
if the message has no parameters.
public ResourceBundle getResourceBundle()
Returns the resource bundle that is used when the message of thisLogRecord
needs to be localized.
- Returns:
- the resource bundle used for localization, or
null
if this message does not need to be localized.
public String getResourceBundleName()
Returns the name of the resource bundle that is used when the message of thisLogRecord
needs to be localized.
- Returns:
- the name of the resource bundle used for localization, or
null
if this message does not need to be localized.
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:
- the name of the class that issued the logging request, or
null
if this information could not be obtained.
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:
- the name of the method that issued the logging request, or
null
if this information could not be obtained.
public int getThreadID()
Returns an identifier for the thread in which thisLogRecord
was created. The identifier is not necessarily related to any thread identifiers used by the operating system.
- Returns:
- an identifier for the source thread.
public Throwable getThrown()
Returns the Throwable associated with thisLogRecord
, ornull
if the logged event is not related to an exception or error.
public void setLevel(Level level)
Sets the severity level of thisLogRecord
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:
level
- the new severity level, for exampleLevel.WARNING
.
public void setLoggerName(String name)
Sets the name of the logger where thisLogRecord
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:
name
- the name of the source logger, ornull
to indicate that thisLogRecord
does not originate from aLogger
.
public void setMessage(String message)
Sets the message for thisLogRecord
.A
Logger
will try to localize the message if a resource bundle has been associated with thisLogRecord
. In this case, the logger will callgetMessage()
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 ofgetMessage()
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:
message
- the message text (which will be used as key for looking up the localized message text if a resource bundle has been associated).
public void setMillis(long millis)
Sets the time when thisLogRecord
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:
millis
- the time of creation in milliseconds since the beginning of January 1, 1970.
public void setParameters(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:
parameters
- the parameters to the message, ornull
to indicate that the message has no parameters.
public void setResourceBundle(ResourceBundle bundle)
Sets the resource bundle that is used when the message of thisLogRecord
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:
bundle
- the resource bundle to be used, ornull
to indicate that this message does not need to be localized.
public void setResourceBundleName(String name)
Sets the name of the resource bundle that is used when the message of thisLogRecord
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:
name
- the name of the resource bundle to be used, ornull
to indicate that this message does not need to be localized.
public void setSequenceNumber(long seqNum)
Sets the sequence number of thisLogRecord
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:
seqNum
- the new sequence number.
public void setSourceClassName(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:
sourceClassName
- the name of the class that issued the logging request, ornull
to indicate that this information could not be obtained.
public void setSourceMethodName(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:
sourceMethodName
- the name of the method that issued the logging request, ornull
to indicate that this information could not be obtained.
public void setThreadID(int threadID)
Sets the identifier indicating in which thread thisLogRecord
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:
threadID
- the identifier for the source thread.
public void setThrown(Throwable thrown)
Associates thisLogRecord
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:
thrown
- the exception or error to associate with, ornull
if thisLogRecord
should be made unrelated to an exception or error.