public final class LogContext extends Object
| Modifier and Type | Method | Description |
|---|---|---|
<V> V |
attach(Logger.AttachmentKey<V> key,
V value) |
Attach an object to this log context under a given key.
|
<V> V |
attachIfAbsent(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> V |
detach(Logger.AttachmentKey<V> key) |
Remove an attachment.
|
<V> V |
getAttachment(String loggerName,
Logger.AttachmentKey<V> key) |
Get a logger attachment for a logger name, if it exists.
|
<V> V |
getAttachment(Logger.AttachmentKey<V> key) |
Get the attachment value for a given key, or
null if there is no such attachment. |
static LogContext |
getInstance() |
Get the system log context.
|
Level |
getLevelForName(String name) |
Get the level for a name.
|
static LogContext |
getLogContext() |
|
Logger |
getLogger(String name) |
Get a logger with the given name from this logging context.
|
Logger |
getLoggerIfExists(String name) |
Get a logger with the given name from this logging context, if a logger node exists at that location.
|
Enumeration<String> |
getLoggerNames() |
Returns an enumeration of the logger names that have been created.
|
public <V> V getAttachment(Logger.AttachmentKey<V> key)
null if there is no such attachment.
Log context attachments are placed on the root logger and can also be accessed there.V - the attachment value typekey - the keynull if there is none for this keypublic <V> V attach(Logger.AttachmentKey<V> key, V value) throws SecurityException
V - the attachment value typekey - the attachment keyvalue - the attachment valueSecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)public <V> V attachIfAbsent(Logger.AttachmentKey<V> key, V value) throws SecurityException
V - the attachment value typekey - the attachment keyvalue - the attachment valuenull if the value was successfully attachedSecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)public <V> V detach(Logger.AttachmentKey<V> key) throws SecurityException
V - the attachment value typekey - the attachment keynull if there was noneSecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)public static LogContext getLogContext()
public Logger getLogger(String name)
name - the logger nameLogManager.getLogger(String)public Logger getLoggerIfExists(String name)
name - the logger namenull if no such logger node existspublic <V> V getAttachment(String loggerName, Logger.AttachmentKey<V> key)
V - the attachment value typeloggerName - the logger namekey - the attachment keynull if the logger or the attachment does not existpublic Level getLevelForName(String name) throws IllegalArgumentException
name - the nameIllegalArgumentException - if the name is not knownpublic static LogContext getInstance()
public Enumeration<String> getLoggerNames()
LogManager.getLoggerNames()Copyright © 2019 JBoss by Red Hat. All rights reserved.