Top Description Inners Fields Constructors Methods
org.jboss.logmanager

public Class ExtLogRecord

extends LogRecord
Class Inheritance
Known Direct Subclasses
org.jboss.logmanager.WrappedExtLogRecord
Static Imports
java.security.AccessController.doPrivileged

An extended log record, which includes additional information including MDC/NDC and correct caller location (even in the presence of a logging facade).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ExtLogRecord.FormatStyle

The format style to use.

Field Summary

Modifier and TypeField and Description
private transient boolean
private ExtLogRecord.FormatStyle
private String
private final transient String
private long
private Object
private FastCopyHashMap<String, Object>
private String
private long
private String
private static final long
private String
private int
private String
private String
private static final MethodHandle
private static final MethodHandle
private String

Constructor Summary

AccessConstructor and Description
public
ExtLogRecord(final Level
a logging level value
level
,
final String
the raw non-localized logging message (may be null)
msg
,
final String
the name of the logger class
loggerClassName
)

Construct a new instance.

public
ExtLogRecord(final Level
a logging level value
level
,
final String
the raw non-localized logging message (may be null)
msg
,
final ExtLogRecord.FormatStyle
the parameter format style to use
formatStyle
,
final String
the name of the logger class
loggerClassName
)

Construct a new instance.

public
ExtLogRecord(final ExtLogRecord
the original
original
)

Make a copy of a log record.

Method Summary

Modifier and TypeMethod and Description
private void
calculateCaller()

Find the first stack frame below the call to the logger, and populate the log record with that information.

public void
copyAll()

Copy all fields and prepare this object to be passed to another thread or to be serialized.

public void
copyMdc()

Copy the MDC.

public void
disableCallerCalculation()

Disable caller calculation for this record.

public ExtLogRecord.FormatStyle

Returns:

the format style
getFormatStyle
()

Get the format style for the record.

public String

Returns:

the formatted log record
getFormattedMessage
()
Deprecated The formatter should normally be used to format the message contents.

Get the fully formatted log record, with resources resolved and parameters applied.

public String

Returns:

the host name of the record, if known
getHostName
()

Get the host name of the record, if known.

public String

Returns:

the class name
getLoggerClassName
()

Get the class name of the logger which created this record.

public long
getLongThreadID()

Overrides java.util.logging.LogRecord.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.

public Object
public String

Returns:

the property value
getMdc
(String
the property key
key
)

Get the value of an MDC property.

public Map<String, String>

Returns:

a copy of the MDC map
getMdcCopy
()

Get a copy of all the MDC properties for this log record.

public String

Returns:

the NDC
getNdc
()

Get the NDC for this log record.

public long

Returns:

the process ID of the record, or -1 if not known
getProcessId
()

Get the process ID of the record, if known.

public String

Returns:

the process name of the record, if known
getProcessName
()

Get the process name of the record, if known.

public String

Returns:

the resource key
getResourceKey
()

Get the resource key, if any.

public String
getSourceClassName()

Overrides java.util.logging.LogRecord.getSourceClassName.

Get the name of the class that (allegedly) issued the logging request.

public String

Returns:

the source file name
getSourceFileName
()

Get the source file name for this log record.

public int

Returns:

the source line number
getSourceLineNumber
()

Get the source line number for this log record.

public String
getSourceMethodName()

Overrides java.util.logging.LogRecord.getSourceMethodName.

Get the name of the method that (allegedly) issued the logging request.

public String

Returns:

the name of the module that initiated the logging request
getSourceModuleName
()

Get the name of the module that initiated the logging request, if known.

public String

Returns:

the version of the module that initiated the logging request
getSourceModuleVersion
()

Get the version of the module that initiated the logging request, if known.

public String

Returns:

the thread name
getThreadName
()

Get the thread name of this logging event.

public String

Returns:

the old value, if any
putMdc
(String
the key to set
key
,
String
the value to set it to
value
)

Change an MDC value on this record.

private void
readObject(ObjectInputStream
the ObjectInputStream to read from
ois
)

Hides java.util.logging.LogRecord.readObject.

Initializes the LogRecord from deserialized data.

public String

Returns:

the old value, if any
removeMdc
(String
the key to remove
key
)

Remove an MDC value on this record.

public void
setHostName(final String
the host name of the record
hostName
)

Set the host name of the record.

public ExtLogRecord
setLongThreadID(final long
the thread ID
id
)

Overrides java.util.logging.LogRecord.setLongThreadID.

Set an identifier for the thread where the message originated.

public void
setMarker(Object marker)

Set the marker for this event.

public void
setMdc(Map<?, ?>
the source man, must not be null
sourceMap
)

Create a new MDC using a copy of the source map.

public void
setMessage(final String
the new raw message
message
)

Overrides java.util.logging.LogRecord.setMessage.

Set the raw message.

public void
setMessage(final String
the new raw message
message
,
final ExtLogRecord.FormatStyle
the format style to use
formatStyle
)

Set the raw message.

public void
setNdc(String
the new NDC value
value
)

Change the NDC for this log record.

public void
setParameters(final Object[]
the log message parameters. (may be null)
parameters
)

Overrides java.util.logging.LogRecord.setParameters.

Set the parameters to the log message.

public void
setProcessId(final long
the process ID of the record
processId
)

Set the process ID of the record.

public void
setProcessName(final String
the process name of the record
processName
)

Set the process name of the record.

public void
setResourceBundle(final ResourceBundle
localization bundle (may be null)
bundle
)

Overrides java.util.logging.LogRecord.setResourceBundle.

Set the localization resource bundle.

public void
setResourceBundleName(final String
localization bundle name (may be null)
name
)

Overrides java.util.logging.LogRecord.setResourceBundleName.

Set the localization resource bundle name.

public void
setSourceClassName(final String
the source class name (may be null)
sourceClassName
)

Overrides java.util.logging.LogRecord.setSourceClassName.

Set the name of the class that (allegedly) issued the logging request.

public void
setSourceFileName(final String
the source file name
sourceFileName
)

Set the source file name for this log record.

public void
setSourceLineNumber(final int
the source line number
sourceLineNumber
)

Set the source line number for this log record.

public void
setSourceMethodName(final String
the source method name (may be null)
sourceMethodName
)

Overrides java.util.logging.LogRecord.setSourceMethodName.

Set the name of the method that (allegedly) issued the logging request.

public void
setSourceModuleName(final String
the source module name
sourceModuleName
)

Set the source module name of this record.

public void
setSourceModuleVersion(final String
the source module version
sourceModuleVersion
)

Set the source module version of this record.

public void
setThreadID(final int
the thread ID
threadID
)

Overrides java.util.logging.LogRecord.setThreadID.

Set an identifier for the thread where the message originated.

public void
setThreadName(final String
the thread name
threadName
)

Set the thread name of this logging event.

pack-priv void
pack-priv long
pack-priv void
superSetLongThreadID(final long id)

public static ExtLogRecord

Returns:

the wrapped record
wrap
(LogRecord
the original record
rec
)

Wrap a JDK log record.

private void
writeObject(ObjectOutputStream
the ObjectOutputStream to write to
oos
)

Hides java.util.logging.LogRecord.writeObject.

Inherited from java.util.logging.LogRecord:
getInstantgetLevelgetLoggerNamegetMessagegetMillisgetParametersgetResourceBundlegetResourceBundleNamegetSequenceNumbergetThreadIDgetThrownsetInstantsetLevelsetLoggerNamesetMillissetSequenceNumbersetThrown

Field Detail

calculateCallerback to summary
private transient boolean calculateCaller
formatStyleback to summary
private ExtLogRecord.FormatStyle formatStyle
hostNameback to summary
private String hostName
loggerClassNameback to summary
private final transient String loggerClassName
longThreadIDback to summary
private long longThreadID

Hides java.util.logging.LogRecord.longThreadID.

markerback to summary
private Object marker
mdcCopyback to summary
private FastCopyHashMap<String, Object> mdcCopy
ndcback to summary
private String ndc
processIdback to summary
private long processId
processNameback to summary
private String processName
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.logging.LogRecord.serialVersionUID.

sourceFileNameback to summary
private String sourceFileName
sourceLineNumberback to summary
private int sourceLineNumber
sourceModuleNameback to summary
private String sourceModuleName
sourceModuleVersionback to summary
private String sourceModuleVersion
superGetLongThreadIDback to summary
private static final MethodHandle superGetLongThreadID
superSetLongThreadIDback to summary
private static final MethodHandle superSetLongThreadID
threadNameback to summary
private String threadName

Constructor Detail

ExtLogRecordback to summary
public ExtLogRecord(final Level level, final String msg, final String loggerClassName)

Construct a new instance. Grabs the current NDC immediately. MDC is deferred.

Parameters
level:Level

a logging level value

msg:String

the raw non-localized logging message (may be null)

loggerClassName:String

the name of the logger class

ExtLogRecordback to summary
public ExtLogRecord(final Level level, final String msg, final ExtLogRecord.FormatStyle formatStyle, final String loggerClassName)

Construct a new instance. Grabs the current NDC immediately. MDC is deferred.

Parameters
level:Level

a logging level value

msg:String

the raw non-localized logging message (may be null)

formatStyle:ExtLogRecord.FormatStyle

the parameter format style to use

loggerClassName:String

the name of the logger class

ExtLogRecordback to summary
public ExtLogRecord(final ExtLogRecord original)

Make a copy of a log record.

Parameters
original:ExtLogRecord

the original

Method Detail

calculateCallerback to summary
private void calculateCaller()

Find the first stack frame below the call to the logger, and populate the log record with that information.

copyAllback to summary
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.

copyMdcback to summary
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.

disableCallerCalculationback to summary
public void disableCallerCalculation()

Disable caller calculation for this record. If the caller has already been calculated, leave it; otherwise set the caller to "unknown".

getFormatStyleback to summary
public ExtLogRecord.FormatStyle getFormatStyle()

Get the format style for the record.

Returns:ExtLogRecord.FormatStyle

the format style

getFormattedMessageback to summary
public String getFormattedMessage()

Deprecated

The formatter should normally be used to format the message contents.

Get the fully formatted log record, with resources resolved and parameters applied.

Returns:String

the formatted log record

Annotations
@Deprecated
getHostNameback to summary
public String getHostName()

Get the host name of the record, if known.

Returns:String

the host name of the record, if known

getLoggerClassNameback to summary
public String getLoggerClassName()

Get the class name of the logger which created this record.

Returns:String

the class name

getLongThreadIDback to summary
public long getLongThreadID()

Overrides java.util.logging.LogRecord.getLongThreadID.

Doc from java.util.logging.LogRecord.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.

Returns:long

thread ID

getMarkerback to summary
public Object getMarker()
getMdcback to summary
public String getMdc(String key)

Get the value of an MDC property.

Parameters
key:String

the property key

Returns:String

the property value

getMdcCopyback to summary
public Map<String, String> getMdcCopy()

Get a copy of all the MDC properties for this log record. If the MDC has not yet been copied, this method will copy it.

Returns:Map<String, String>

a copy of the MDC map

getNdcback to summary
public String getNdc()

Get the NDC for this log record.

Returns:String

the NDC

getProcessIdback to summary
public long getProcessId()

Get the process ID of the record, if known.

Returns:long

the process ID of the record, or -1 if not known

getProcessNameback to summary
public String getProcessName()

Get the process name of the record, if known.

Returns:String

the process name of the record, if known

getResourceKeyback to summary
public String getResourceKey()

Get the resource key, if any. If the log message is not localized, then the key is null.

Returns:String

the resource key

getSourceClassNameback to summary
public String getSourceClassName()

Overrides java.util.logging.LogRecord.getSourceClassName.

Doc from java.util.logging.LogRecord.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.

Returns:String

the source class name

getSourceFileNameback to summary
public String 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 be null if no information could be obtained.

Returns:String

the source file name

getSourceLineNumberback to summary
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:int

the source line number

getSourceMethodNameback to summary
public String getSourceMethodName()

Overrides java.util.logging.LogRecord.getSourceMethodName.

Doc from java.util.logging.LogRecord.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.

Returns:String

the source method name

getSourceModuleNameback to summary
public String getSourceModuleName()

Get the name of the module that initiated the logging request, if known.

Returns:String

the name of the module that initiated the logging request

getSourceModuleVersionback to summary
public String getSourceModuleVersion()

Get the version of the module that initiated the logging request, if known.

Returns:String

the version of the module that initiated the logging request

getThreadNameback to summary
public String getThreadName()

Get the thread name of this logging event.

Returns:String

the thread name

putMdcback to summary
public String putMdc(String key, String value)

Change an MDC value on this record. If the MDC has not yet been copied, this method will copy it.

Parameters
key:String

the key to set

value:String

the value to set it to

Returns:String

the old value, if any

readObjectback to summary
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException

Hides java.util.logging.LogRecord.readObject.

Doc from java.util.logging.LogRecord.readObject.

Initializes the LogRecord from deserialized data.

  • If longThreadID is present in the serial form, its value takes precedence over threadID and a value for threadID is synthesized from it, such that for longThreadID values between 0 and Integer.MAX_VALUE inclusive, longThreadID and threadID will have the same value. For values outside of this range a negative synthesized value will be deterministically derived from longThreadID.
  • Otherwise, when only threadID is present, longThreadID is initialized with the value of threadID which may be anything between Integer.MIN_VALUE and {Integer.MAX_VALUE}.
See writeObject for a description of the serial form.
Parameters
ois:ObjectInputStream

the ObjectInputStream to read from

Annotations
@SuppressWarnings:unchecked
Exceptions
IOException:
if an I/O error occurs.
ClassNotFoundException:
if the class of a serialized object could not be found.
removeMdcback to summary
public String removeMdc(String key)

Remove an MDC value on this record. If the MDC has not yet been copied, this method will copy it.

Parameters
key:String

the key to remove

Returns:String

the old value, if any

setHostNameback to summary
public void setHostName(final String hostName)

Set the host name of the record.

Parameters
hostName:String

the host name of the record

setLongThreadIDback to summary
public ExtLogRecord setLongThreadID(final long id)

Overrides java.util.logging.LogRecord.setLongThreadID.

Doc from java.util.logging.LogRecord.setLongThreadID.

Set an identifier for the thread where the message originated.

Parameters
id:long

the thread ID

Returns:ExtLogRecord

this LogRecord

setMarkerback to summary
public void setMarker(Object marker)

Set the marker for this event. Markers are used mostly by SLF4J and Log4j.

setMdcback to summary
public void setMdc(Map<?, ?> sourceMap)

Create a new MDC using a copy of the source map.

Parameters
sourceMap:Map<?, ?>

the source man, must not be null

setMessageback to summary
public void setMessage(final String message)

Overrides java.util.logging.LogRecord.setMessage.

Set the raw message. Any cached formatted message is discarded. The parameter format is set to be java.text.MessageFormat-style.

Parameters
message:String

the new raw message

setMessageback to summary
public void setMessage(final String message, final ExtLogRecord.FormatStyle formatStyle)

Set the raw message. Any cached formatted message is discarded. The parameter format is set according to the given argument.

Parameters
message:String

the new raw message

formatStyle:ExtLogRecord.FormatStyle

the format style to use

setNdcback to summary
public void setNdc(String value)

Change the NDC for this log record.

Parameters
value:String

the new NDC value

setParametersback to summary
public void setParameters(final Object[] parameters)

Overrides java.util.logging.LogRecord.setParameters.

Set the parameters to the log message. Any cached formatted message is discarded.

Parameters
parameters:Object[]

the log message parameters. (may be null)

setProcessIdback to summary
public void setProcessId(final long processId)

Set the process ID of the record.

Parameters
processId:long

the process ID of the record

setProcessNameback to summary
public void setProcessName(final String processName)

Set the process name of the record.

Parameters
processName:String

the process name of the record

setResourceBundleback to summary
public void setResourceBundle(final ResourceBundle bundle)

Overrides java.util.logging.LogRecord.setResourceBundle.

Set the localization resource bundle. Any cached formatted message is discarded.

Parameters
bundle:ResourceBundle

localization bundle (may be null)

setResourceBundleNameback to summary
public void setResourceBundleName(final String name)

Overrides java.util.logging.LogRecord.setResourceBundleName.

Set the localization resource bundle name. Any cached formatted message is discarded.

Parameters
name:String

localization bundle name (may be null)

setSourceClassNameback to summary
public void setSourceClassName(final String sourceClassName)

Overrides java.util.logging.LogRecord.setSourceClassName.

Doc from java.util.logging.LogRecord.setSourceClassName.

Set the name of the class that (allegedly) issued the logging request.

Parameters
sourceClassName:String

the source class name (may be null)

setSourceFileNameback to summary
public void setSourceFileName(final String sourceFileName)

Set the source file name for this log record.

Parameters
sourceFileName:String

the source file name

setSourceLineNumberback to summary
public void setSourceLineNumber(final int sourceLineNumber)

Set the source line number for this log record.

Parameters
sourceLineNumber:int

the source line number

setSourceMethodNameback to summary
public void setSourceMethodName(final String sourceMethodName)

Overrides java.util.logging.LogRecord.setSourceMethodName.

Doc from java.util.logging.LogRecord.setSourceMethodName.

Set the name of the method that (allegedly) issued the logging request.

Parameters
sourceMethodName:String

the source method name (may be null)

setSourceModuleNameback to summary
public void setSourceModuleName(final String sourceModuleName)

Set the source module name of this record.

Parameters
sourceModuleName:String

the source module name

setSourceModuleVersionback to summary
public void setSourceModuleVersion(final String sourceModuleVersion)

Set the source module version of this record.

Parameters
sourceModuleVersion:String

the source module version

setThreadIDback to summary
public void setThreadID(final int threadID)

Overrides java.util.logging.LogRecord.setThreadID.

Doc from java.util.logging.LogRecord.setThreadID.

Set an identifier for the thread where the message originated.

Parameters
threadID:int

the thread ID

Annotations
@Override
setThreadNameback to summary
public void setThreadName(final String threadName)

Set the thread name of this logging event.

Parameters
threadName:String

the thread name

setUnknownCallerback to summary
pack-priv void setUnknownCaller()
superGetLongThreadIDback to summary
pack-priv long superGetLongThreadID()
superSetLongThreadIDback to summary
pack-priv void superSetLongThreadID(final long id)
wrapback to summary
public static ExtLogRecord wrap(LogRecord rec)

Wrap a JDK log record. If the target record is already an ExtLogRecord, it is simply returned. Otherwise a wrapper record is created and returned.

Parameters
rec:LogRecord

the original record

Returns:ExtLogRecord

the wrapped record

writeObjectback to summary
private void writeObject(ObjectOutputStream oos) throws IOException

Hides java.util.logging.LogRecord.writeObject.

Parameters
oos:ObjectOutputStream

Doc from java.util.logging.LogRecord.writeObject.

the ObjectOutputStream to write to

Exceptions
IOException:

Doc from java.util.logging.LogRecord.writeObject.

if I/O errors occur

org.jboss.logmanager back to summary

public final Enum ExtLogRecord.FormatStyle

extends Enum<ExtLogRecord.FormatStyle>
Class Inheritance

The format style to use.

Field Summary

Modifier and TypeField and Description
public static final ExtLogRecord.FormatStyle
MESSAGE_FORMAT

Format the message using the java.text.MessageFormat parameter style.

public static final ExtLogRecord.FormatStyle
NO_FORMAT

Do not format the message; parameters are ignored.

public static final ExtLogRecord.FormatStyle
PRINTF

Format the message using the java.util.Formatter (also known as printf()) parameter style.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ExtLogRecord.FormatStyle
public static ExtLogRecord.FormatStyle[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

MESSAGE_FORMATback to summary
public static final ExtLogRecord.FormatStyle MESSAGE_FORMAT

Format the message using the java.text.MessageFormat parameter style.

NO_FORMATback to summary
public static final ExtLogRecord.FormatStyle NO_FORMAT

Do not format the message; parameters are ignored.

PRINTFback to summary
public static final ExtLogRecord.FormatStyle PRINTF

Format the message using the java.util.Formatter (also known as printf()) parameter style.

Constructor Detail

FormatStyleback to summary
private FormatStyle()

Method Detail

valueOfback to summary
public static ExtLogRecord.FormatStyle valueOf(String name)
valuesback to summary
public static ExtLogRecord.FormatStyle[] values()