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:
Modifier and Type | Class and Description |
---|---|
pack-priv static class |
Modifier and Type | Field and Description |
---|---|
private static final AtomicLong | |
private Instant | instant
Event time. |
private Level | level
Logging message level |
private String | loggerName
Name of the source Logger. |
private long | longThreadID
long value of Thread ID for thread that issued logging call. |
private String | message
Non-localized raw message text |
private transient boolean | |
private transient Object[] | |
private transient ResourceBundle | |
private String | resourceBundleName
Resource bundle name to localized log message. |
private long | sequenceNumber
Sequence number |
private static final ObjectStreamField[] | |
private static final long | |
private String | sourceClassName
Class that issued logging call |
private String | sourceMethodName
Method that issued logging call |
private int | threadID
Thread ID for thread that issued logging call. |
private Throwable | thrown
The Throwable (if any) associated with log message |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public Instant | |
public Level | Returns: the logging message levelGet the logging message level, for example Level.SEVERE. |
public String | |
public long | Returns: thread IDGet a thread identifier for the thread where message originated This is a thread identifier within the Java VM and may or may not map to any operating system ID. |
public String | Returns: the raw message stringGet the "raw" log message, before localization or formatting. |
public long | Returns: truncated event time in millis since 1970Get truncated event time in milliseconds since 1970. |
public Object[] | Returns: the log message parameters. May be null if there are no parameters.Get the parameters to the log message. |
public ResourceBundle | Returns: the localization resource bundleGet the localization resource bundle This is the ResourceBundle that should be used to localize the message string before formatting it. |
public String | Returns: the localization resource bundle nameGet the localization resource bundle name This is the name for the ResourceBundle that should be used to localize the message string before formatting it. |
public long | |
public String | Returns: the source class nameGet the name of the class that (allegedly) issued the logging request. |
public String | Returns: the source method nameGet the name of the method that (allegedly) issued the logging request. |
public int | Returns: thread ID
Deprecated
since 16. Values returned by this method may be synthesized,
and may not correspond to the actual thread id,
use
getLongThreadID() instead.
Get an identifier for the thread where the message originated. |
public Throwable | |
private void | |
private void | readObject(ObjectInputStream
the in)ObjectInputStream to read fromInitializes the LogRecord from deserialized data. |
public void | setInstant(Instant
the instant that the event occurred. instant)Sets the instant that the event occurred. |
public void | |
public void | |
public LogRecord | Returns: this LogRecordthe thread ID longThreadID)Set an identifier for the thread where the message originated. |
public void | setMessage(String
the raw message string (may be null) message)Set the "raw" log message, before localization or formatting. |
public void | |
public void | setParameters(Object[]
the log message parameters. (may be null) parameters)Set the parameters to the log message. |
public void | setResourceBundle(ResourceBundle
localization bundle (may be null) bundle)Set the localization resource bundle. |
public void | setResourceBundleName(String
localization bundle name (may be null) name)Set the localization resource bundle name. |
public void | |
public void | setSourceClassName(String
the source class name (may be null) sourceClassName)Set the name of the class that (allegedly) issued the logging request. |
public void | setSourceMethodName(String
the source method name (may be null) sourceMethodName)Set the name of the method that (allegedly) issued the logging request. |
public void | setThreadID(int
the thread ID threadID)
Deprecated
since 16. This method doesn't allow to pass a long thread id,
use
setLongThreadID(long) instead.
Set an identifier for the thread where the message originated. |
public void | |
private int | Returns: thread idSynthesizes a pseudo unique integer value from a long |
private void |
globalSequenceNumber | back to summary |
---|---|
private static final AtomicLong globalSequenceNumber |
instant | back to summary |
---|---|
private Instant instant Event time.
|
level | back to summary |
---|---|
private Level level Logging message level |
loggerName | back to summary |
---|---|
private String loggerName Name of the source Logger. |
longThreadID | back to summary |
---|---|
private long longThreadID long value of Thread ID for thread that issued logging call. |
message | back to summary |
---|---|
private String message Non-localized raw message text |
needToInferCaller | back to summary |
---|---|
private transient boolean needToInferCaller |
parameters | back to summary |
---|---|
private transient Object[] parameters |
resourceBundle | back to summary |
---|---|
private transient ResourceBundle resourceBundle |
resourceBundleName | back to summary |
---|---|
private String resourceBundleName Resource bundle name to localized log message. |
sequenceNumber | back to summary |
---|---|
private long sequenceNumber Sequence number |
serialPersistentFields | back to summary |
---|---|
private static final ObjectStreamField[] serialPersistentFields
|
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID
|
sourceClassName | back to summary |
---|---|
private String sourceClassName Class that issued logging call |
sourceMethodName | back to summary |
---|---|
private String sourceMethodName Method that issued logging call |
threadID | back to summary |
---|---|
private int threadID Thread ID for thread that issued logging call. |
thrown | back to summary |
---|---|
private Throwable thrown The Throwable (if any) associated with log message |
LogRecord | back to summary |
---|---|
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.
Since JDK 9, the event time is represented by an The thread ID property will be initialized with a unique ID for the current thread. All other properties will be initialized to "null".
|
getInstant | back to summary |
---|---|
public Instant getInstant() Gets the instant that the event occurred.
|
getLevel | back to summary |
---|---|
public Level getLevel() Get the logging message level, for example Level.SEVERE.
|
getLoggerName | back to summary |
---|---|
public String getLoggerName() Get the source Logger's name.
|
getLongThreadID | back to summary |
---|---|
public long getLongThreadID() Get a thread identifier for the thread where message originated This is a thread identifier within the Java VM and may or may not map to any operating system ID.
|
getMessage | back to summary |
---|---|
public String getMessage() Get the "raw" log message, before localization or formatting. May be null, which is equivalent to the empty string "". This message may be either the final text or a localization key. During formatting, if the source logger has a localization ResourceBundle and if that ResourceBundle has an entry for this message string, then the message string is replaced with the localized value.
|
getMillis | back to summary |
---|---|
public long getMillis() Get truncated event time in milliseconds since 1970. Implementation Specification This is equivalent to calling
API Note To get the full nanosecond resolution event time,
use
|
getParameters | back to summary |
---|---|
public Object[] getParameters() Get the parameters to the log message.
|
getResourceBundle | back to summary |
---|---|
public ResourceBundle getResourceBundle() Get the localization resource bundle This is the ResourceBundle that should be used to localize the message string before formatting it. The result may be null if the message is not localizable, or if no suitable ResourceBundle is available.
|
getResourceBundleName | back to summary |
---|---|
public 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. The result may be null if the message is not localizable.
|
getSequenceNumber | back to summary |
---|---|
public long getSequenceNumber() Get the sequence number. Sequence numbers are normally assigned in the LogRecord constructor, which assigns unique sequence numbers to each new LogRecord in increasing order.
|
getSourceClassName | back to summary |
---|---|
public String getSourceClassName() Get the name of the class that (allegedly) issued the logging request. Note that this sourceClassName is not verified and may be spoofed. This information may either have been provided as part of the logging call, or it may have been inferred automatically by the logging framework. In the latter case, the information may only be approximate and may in fact describe an earlier call on the stack frame. May be null if no information could be obtained.
|
getSourceMethodName | back to summary |
---|---|
public String getSourceMethodName() Get the name of the method that (allegedly) issued the logging request. Note that this sourceMethodName is not verified and may be spoofed. This information may either have been provided as part of the logging call, or it may have been inferred automatically by the logging framework. In the latter case, the information may only be approximate and may in fact describe an earlier call on the stack frame. May be null if no information could be obtained.
|
getThreadID | back to summary |
---|---|
public int getThreadID()
Deprecated since 16. Values returned by this method may be synthesized,
and may not correspond to the actual thread id,
use Get an identifier for the thread where the message originated. This is a thread identifier within the Java VM and may or may not map to any operating system ID.
|
getThrown | back to summary |
---|---|
public Throwable getThrown() Get any throwable associated with the log record. If the event involved an exception, this will be the exception object. Otherwise null.
|
inferCaller | back to summary |
---|---|
private void inferCaller() |
readObject | back to summary |
---|---|
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException Initializes the LogRecord from deserialized data.
writeObject for a description of the serial form.
|
setInstant | back to summary |
---|---|
public void setInstant(Instant instant) Sets the instant that the event occurred.
If the given
|
setLevel | back to summary |
---|---|
public void setLevel(Level level) Set the logging message level, for example Level.SEVERE.
|
setLoggerName | back to summary |
---|---|
public void setLoggerName(String name) Set the source Logger's name.
|
setLongThreadID | back to summary |
---|---|
public LogRecord setLongThreadID(long longThreadID) Set an identifier for the thread where the message originated.
|
setMessage | back to summary |
---|---|
public void setMessage(String message) Set the "raw" log message, before localization or formatting.
|
setMillis | back to summary |
---|---|
public void setMillis(long millis)
Deprecated LogRecord maintains timestamps with nanosecond resolution,
using Set event time. Implementation Specification This is equivalent to calling
|
setParameters | back to summary |
---|---|
public void setParameters(Object[] parameters) Set the parameters to the log message.
|
setResourceBundle | back to summary |
---|---|
public void setResourceBundle(ResourceBundle bundle) Set the localization resource bundle.
|
setResourceBundleName | back to summary |
---|---|
public void setResourceBundleName(String name) Set the localization resource bundle name.
|
setSequenceNumber | back to summary |
---|---|
public void setSequenceNumber(long seq) Set the sequence number. Sequence numbers are normally assigned in the LogRecord constructor, so it should not normally be necessary to use this method.
|
setSourceClassName | back to summary |
---|---|
public void setSourceClassName(String sourceClassName) Set the name of the class that (allegedly) issued the logging request.
|
setSourceMethodName | back to summary |
---|---|
public void setSourceMethodName(String sourceMethodName) Set the name of the method that (allegedly) issued the logging request.
|
setThreadID | back to summary |
---|---|
public void setThreadID(int threadID)
Deprecated since 16. This method doesn't allow to pass a long thread id,
use Set an identifier for the thread where the message originated.
|
setThrown | back to summary |
---|---|
public void setThrown(Throwable thrown) Set a throwable associated with the log event.
|
shortThreadID | back to summary |
---|---|
private int shortThreadID(long id) Synthesizes a pseudo unique integer value from a long
|
writeObject | back to summary |
---|---|
private void writeObject(ObjectOutputStream out) throws IOException
|
Modifier and Type | Field and Description |
---|---|
private boolean | |
private static final StackWalker |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
pack-priv Optional | |
private boolean | |
public boolean | Returns: true if we have found the caller's frame, false if the frame must be skipped.The frame info. tImplements java. Returns true if we have found the caller's frame, false if the frame must be skipped. |
lookingForLogger | back to summary |
---|---|
private boolean lookingForLogger |
WALKER | back to summary |
---|---|
private static final StackWalker WALKER |
CallerFinder | back to summary |
---|---|
pack-priv CallerFinder() |
get | back to summary |
---|---|
pack-priv Optional Returns StackFrame of the caller's frame.
|
isLoggerImplFrame | back to summary |
---|---|
private boolean isLoggerImplFrame(String cname) |
test | back to summary |
---|---|
public boolean test(StackWalker. Implements java. Returns true if we have found the caller's frame, false if the frame must be skipped.
|