Package java.util.logging
Class LogRecord
- java.lang.Object
-
- java.util.logging.LogRecord
-
public class LogRecord extends Object
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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LevelgetLevel()Get the logging message level.StringgetLoggerName()Get the name of the logger that logged this LogRecord.StringgetMessage()Get the raw log message.longgetMillis()Get event time in milliseconds since 1970.longgetSequenceNumber()Get the sequence number of the LogRecord.ThrowablegetThrown()Get the throwable associated with this log record, if any.voidsetLevel(Level level)Set the logging message level.voidsetLoggerName(String name)Set the source logger's name.voidsetMessage(String message)Set the raw log message.voidsetMillis(long millis)Set event time of the LogRecord.voidsetThrown(Throwable thrown)Set the throwable associated with this log record.
-
-
-
Method Detail
-
getLoggerName
@Nullable public String getLoggerName()
Get the name of the logger that logged this LogRecord.- Returns:
- source logger name (may be
null).
-
setLoggerName
public void setLoggerName(@Nullable String name)
Set the source logger's name.- Parameters:
name- the source logger's name (may benull).
-
getLevel
public Level getLevel()
Get the logging message level.- Returns:
- the logging message level.
-
setLevel
public void setLevel(Level level)
Set the logging message level.- Parameters:
level- the logging message level.
-
getSequenceNumber
public long getSequenceNumber()
Get the sequence number of the LogRecord. This number is normally a unique identifier assigned by the constructor.- Returns:
- the sequence number of the LogRecord.
-
getMessage
@Nullable public String getMessage()
Get the raw log message.- Returns:
- the message string (may be
null).
-
setMessage
public void setMessage(@Nullable String message)
Set the raw log message.- Parameters:
message- the message to set (may benull).
-
getMillis
public long getMillis()
Get event time in milliseconds since 1970. This is the creation time of the LogRecord.- Returns:
- event time in milliseconds.
-
setMillis
public void setMillis(long millis)
Set event time of the LogRecord.- Parameters:
millis- event time.
-
getThrown
@Nullable public Throwable getThrown()
Get the throwable associated with this log record, if any.- Returns:
- a throwable (may be
null).
-
-