public final class LogContext extends Object implements Protectable
| Modifier and Type | Field and Description |
|---|---|
static LogContextSelector |
DEFAULT_LOG_CONTEXT_SELECTOR
The default log context selector, which always returns the system log context.
|
| Modifier and Type | Method and Description |
|---|---|
static LogContext |
create()
Create a new log context.
|
void |
disableAccess()
Disable previous access to the object for modifications on the current thread.
|
void |
enableAccess(Object protectKey)
Enable access to the object for modifications on the current thread.
|
<V> V |
getAttachment(String loggerName,
Logger.AttachmentKey<V> key)
Get a logger attachment for a logger name, if it exists.
|
Level |
getLevelForName(String name)
Get the level for a name.
|
static LogContext |
getLogContext()
Get the currently active log context.
|
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.
|
LoggingMXBean |
getLoggingMXBean()
Get the
LoggingMXBean associated with this log context. |
static LogContext |
getSystemLogContext()
Get the system log context.
|
void |
protect(Object protectionKey)
Protect this object from modifications.
|
void |
registerLevel(Level level)
Register a level instance with this log context.
|
static void |
setLogContextSelector(LogContextSelector newSelector)
Set a new log context selector.
|
void |
unprotect(Object protectionKey)
Allows the object to be modified if the
protectionKey matches the key used to protect the object. |
void |
unregisterLevel(Level level)
Unregister a previously registered level.
|
public static final LogContextSelector DEFAULT_LOG_CONTEXT_SELECTOR
public static LogContext create()
"createLogContext"
RuntimePermission to invoke this method.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 LoggingMXBean getLoggingMXBean()
LoggingMXBean associated with this log context.LoggingMXBean instancepublic Level getLevelForName(String name) throws IllegalArgumentException
name - the nameIllegalArgumentException - if the name is not knownpublic void registerLevel(Level level)
level - the level to registerpublic void unregisterLevel(Level level)
level - the level to unregisterpublic static LogContext getSystemLogContext()
public static LogContext getLogContext()
public static void setLogContextSelector(LogContextSelector newSelector)
"setLogContextSelector"
RuntimePermission to invoke this method.newSelector - the new selector.public void protect(Object protectionKey) throws SecurityException
Protectableprotect in interface ProtectableprotectionKey - the key used to protect the object.SecurityException - if the object is already protected.public void unprotect(Object protectionKey) throws SecurityException
ProtectableprotectionKey matches the key used to protect the object.unprotect in interface ProtectableprotectionKey - the key used to protect the object.SecurityException - if the object is protected and the key doesn't match.public void enableAccess(Object protectKey) throws SecurityException
ProtectableenableAccess in interface ProtectableprotectKey - the key used to protect modifications.SecurityExceptionpublic void disableAccess()
ProtectabledisableAccess in interface ProtectableCopyright © 2012 JBoss by Red Hat. All Rights Reserved.