Package org.jboss.logmanager
Class LogContext
java.lang.Object
org.jboss.logmanager.LogContext
A logging context, for producing isolated logging environments.
-
Method Summary
Modifier and TypeMethodDescription<V> Vattach(Logger.AttachmentKey<V> key, V value) Attach an object to this log context under a given key.<V> VattachIfAbsent(Logger.AttachmentKey<V> key, V value) Attach an object to this log context under a given key, if such an attachment does not already exist.<V> Vdetach(Logger.AttachmentKey<V> key) Remove an attachment.<V> VgetAttachment(String loggerName, Logger.AttachmentKey<V> key) Get a logger attachment for a logger name, if it exists.<V> VgetAttachment(Logger.AttachmentKey<V> key) Get the attachment value for a given key, ornullif there is no such attachment.static LogContextGet the system log context.getLevelForName(String name) Get the level for a name.static LogContextGet a logger with the given name from this logging context.getLoggerIfExists(String name) Get a logger with the given name from this logging context, if a logger node exists at that location.Returns an enumeration of the logger names that have been created.
-
Method Details
-
getAttachment
Get the attachment value for a given key, ornullif there is no such attachment. Log context attachments are placed on the root logger and can also be accessed there.- Type Parameters:
V- the attachment value type- Parameters:
key- the key- Returns:
- the attachment, or
nullif there is none for this key
-
attach
Attach an object to this log context under a given key. A strong reference is maintained to the key and value for as long as this log context exists. Log context attachments are placed on the root logger and can also be accessed there.- Type Parameters:
V- the attachment value type- Parameters:
key- the attachment keyvalue- the attachment value- Returns:
- the old attachment, if there was one
- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
attachIfAbsent
Attach an object to this log context under a given key, if such an attachment does not already exist. A strong reference is maintained to the key and value for as long as this log context exists. Log context attachments are placed on the root logger and can also be accessed there.- Type Parameters:
V- the attachment value type- Parameters:
key- the attachment keyvalue- the attachment value- Returns:
- the current attachment, if there is one, or
nullif the value was successfully attached - Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
detach
Remove an attachment. Log context attachments are placed on the root logger and can also be accessed there.- Type Parameters:
V- the attachment value type- Parameters:
key- the attachment key- Returns:
- the old value, or
nullif there was none - Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
getLogContext
-
getLogger
Get a logger with the given name from this logging context.- Parameters:
name- the logger name- Returns:
- the logger instance
- See Also:
-
getLoggerIfExists
Get a logger with the given name from this logging context, if a logger node exists at that location.- Parameters:
name- the logger name- Returns:
- the logger instance, or
nullif no such logger node exists
-
getAttachment
Get a logger attachment for a logger name, if it exists.- Type Parameters:
V- the attachment value type- Parameters:
loggerName- the logger namekey- the attachment key- Returns:
- the attachment or
nullif the logger or the attachment does not exist
-
getLevelForName
Get the level for a name.- Parameters:
name- the name- Returns:
- the level
- Throws:
IllegalArgumentException- if the name is not known
-
getInstance
Get the system log context.- Returns:
- the system log context
-
getLoggerNames
Returns an enumeration of the logger names that have been created. This does not return names of loggers that may have been garbage collected. Logger names added after the enumeration has been retrieved may also be added to the enumeration.- Returns:
- an enumeration of the logger names
- See Also:
-