Class ExtLogRecord
java.lang.Object
java.util.logging.LogRecord
org.jboss.logmanager.ExtLogRecord
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
WrappedExtLogRecord
An extended log record, which includes additional information including MDC/NDC and correct
caller location (even in the presence of a logging facade).
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate ExtLogRecord.FormatStyleprivate Stringprivate final Stringprivate FastCopyHashMap<String, Object> private Stringprivate Stringprivate static final longprivate Stringprivate intprivate String -
Constructor Summary
ConstructorsConstructorDescriptionExtLogRecord(Level level, String msg, String loggerClassName) Construct a new instance.ExtLogRecord(Level level, String msg, ExtLogRecord.FormatStyle formatStyle, String loggerClassName) Construct a new instance.ExtLogRecord(ExtLogRecord original) Make a copy of a log record. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidFind the first stack frame below the call to the logger, and populate the log record with that information.voidcopyAll()Copy all fields and prepare this object to be passed to another thread or to be serialized.voidcopyMdc()Copy the MDC.voidDisable caller calculation for this record.private StringGet the format style for the record.Get the fully formatted log record, with resources resolved and parameters applied.Get the class name of the logger which created this record.Get the value of an MDC property.Get a copy of all the MDC properties for this log record.getNdc()Get the NDC for this log record.Get the resource key, if any.Get the source file name for this log record.intGet the source line number for this log record.Get the thread name of this logging event.Change an MDC value on this record.Remove an MDC value on this record.voidCreate a new MDC using a copy of the source map.voidsetMessage(String message) Set the raw message.voidsetMessage(String message, ExtLogRecord.FormatStyle formatStyle) Set the raw message.voidChange the NDC for this log record.voidsetParameters(Object[] parameters) Set the parameters to the log message.voidsetResourceBundle(ResourceBundle bundle) Set the localization resource bundle.voidsetResourceBundleName(String name) Set the localization resource bundle name.voidsetSourceClassName(String sourceClassName) voidsetSourceFileName(String sourceFileName) Set the source file name for this log record.voidsetSourceLineNumber(int sourceLineNumber) Set the source line number for this log record.voidsetSourceMethodName(String sourceMethodName) voidsetThreadName(String threadName) Set the thread name of this logging event.private voidstatic ExtLogRecordWrap a JDK log record.private voidMethods inherited from class LogRecord
getInstant, getLevel, getLoggerName, getLongThreadID, getMessage, getMillis, getParameters, getResourceBundle, getResourceBundleName, getSequenceNumber, getThreadID, getThrown, setInstant, setLevel, setLoggerName, setLongThreadID, setMillis, setSequenceNumber, setThreadID, setThrown
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
loggerClassName
-
calculateCaller
private transient boolean calculateCaller -
ndc
-
formatStyle
-
mdcCopy
-
sourceLineNumber
private int sourceLineNumber -
sourceFileName
-
resourceKey
-
formattedMessage
-
threadName
-
-
Constructor Details
-
ExtLogRecord
-
ExtLogRecord
public ExtLogRecord(Level level, String msg, ExtLogRecord.FormatStyle formatStyle, String loggerClassName) Construct a new instance. Grabs the current NDC immediately. MDC is deferred.- Parameters:
level- a logging level valuemsg- the raw non-localized logging message (may be null)formatStyle- the parameter format style to useloggerClassName- the name of the logger class
-
ExtLogRecord
Make a copy of a log record.- Parameters:
original- the original
-
-
Method Details
-
wrap
Wrap a JDK log record. If the target record is already anExtLogRecord, it is simply returned. Otherwise a wrapper record is created and returned.- Parameters:
rec- the original record- Returns:
- the wrapped record
-
writeObject
- Throws:
IOException
-
disableCallerCalculation
public void disableCallerCalculation()Disable caller calculation for this record. If the caller has already been calculated, leave it; otherwise set the caller to"unknown". -
copyAll
public void copyAll()Copy all fields and prepare this object to be passed to another thread or to be serialized. Calling this method more than once has no additional effect and will not incur extra copies. -
copyMdc
public void copyMdc()Copy the MDC. Call this method before passing this log record to another thread. Calling this method more than once has no additional effect and will not incur extra copies. -
getMdc
-
getMdcCopy
-
putMdc
-
removeMdc
-
setMdc
Create a new MDC using a copy of the source map.- Parameters:
sourceMap- the source man, must not benull
-
getNdc
-
setNdc
Change the NDC for this log record.- Parameters:
value- the new NDC value
-
getLoggerClassName
Get the class name of the logger which created this record.- Returns:
- the class name
-
getFormatStyle
Get the format style for the record.- Returns:
- the format style
-
calculateCaller
private void calculateCaller()Find the first stack frame below the call to the logger, and populate the log record with that information. -
setUnknownCaller
private void setUnknownCaller() -
getSourceLineNumber
public int getSourceLineNumber()Get the source line number for this log record. Note that this line number 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 -1 if no information could be obtained.- Returns:
- the source line number
-
setSourceLineNumber
public void setSourceLineNumber(int sourceLineNumber) Set the source line number for this log record.- Parameters:
sourceLineNumber- the source line number
-
getSourceFileName
Get the source file name for this log record. Note that this file name 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 benullif no information could be obtained.- Returns:
- the source file name
-
setSourceFileName
Set the source file name for this log record.- Parameters:
sourceFileName- the source file name
-
getSourceClassName
- Overrides:
getSourceClassNamein classLogRecord
-
setSourceClassName
- Overrides:
setSourceClassNamein classLogRecord
-
getSourceMethodName
- Overrides:
getSourceMethodNamein classLogRecord
-
setSourceMethodName
- Overrides:
setSourceMethodNamein classLogRecord
-
getFormattedMessage
Get the fully formatted log record, with resources resolved and parameters applied.- Returns:
- the formatted log record
-
getResourceKey
Get the resource key, if any. If the log message is not localized, then the key isnull.- Returns:
- the resource key
-
formatRecord
-
getThreadName
-
setThreadName
Set the thread name of this logging event.- Parameters:
threadName- the thread name
-
setMessage
Set the raw message. Any cached formatted message is discarded. The parameter format is set to beMessageFormat-style.- Overrides:
setMessagein classLogRecord- Parameters:
message- the new raw message
-
setMessage
Set the raw message. Any cached formatted message is discarded. The parameter format is set according to the given argument.- Parameters:
message- the new raw messageformatStyle- the format style to use
-
setParameters
Set the parameters to the log message. Any cached formatted message is discarded.- Overrides:
setParametersin classLogRecord- Parameters:
parameters- the log message parameters. (may be null)
-
setResourceBundle
Set the localization resource bundle. Any cached formatted message is discarded.- Overrides:
setResourceBundlein classLogRecord- Parameters:
bundle- localization bundle (may be null)
-
setResourceBundleName
Set the localization resource bundle name. Any cached formatted message is discarded.- Overrides:
setResourceBundleNamein classLogRecord- Parameters:
name- localization bundle name (may be null)
-