|
SLF4J API Version 1.4.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.slf4j.MDC
public class MDC
This class hides and serves as a substitute for the underlying logging system's MDC implementation.
If the underlying logging system offers MDC functionality, then SLF4J's MDC, i.e. this class, will delegate to the underlying system's MDC. Note that at this time, only two logging systems, namely log4j and logback, offer MDC functionality. If the undelying system does not support MDC, then SLF4J will silently drop MDC information.
Thus, as a SLF4J user, you can take advantage of MDC in the presence of log4j or logback, but without forcing log4j or logback as dependencies upon your users.
For more information on MDC please see the chapter on MDC in the logback manual.
Please note that all methods in this class are static.
Method Summary | |
---|---|
static void |
clear()
Clear all entries in the MDC of the underlying implementation. |
static String |
get(String key)
Get the context identified by the key parameter. |
static MDCAdapter |
getMDCAdapter()
Returns the MDCAdapter instance currently in use. |
static void |
put(String key,
String val)
Put a context value (the val parameter) as identified with
the key parameter into the current thread's context map. |
static void |
remove(String key)
Remove the the context identified by the key parameter using
the underlying system's MDC implementation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void put(String key, String val) throws IllegalArgumentException
val
parameter) as identified with
the key
parameter into the current thread's context map.
The key
parameter cannot be null. The code>val parameter
can be null only if the underlying implementation supports it.
This method delegates all work to the MDC of the underlying logging system.
IllegalArgumentException
- in case the "key" parameter is nullpublic static String get(String key) throws IllegalArgumentException
key
parameter. The
key
parameter cannot be null.
This method delegates all work to the MDC of the underlying logging system.
key
parameter.
IllegalArgumentException
- in case the "key" parameter is nullpublic static void remove(String key) throws IllegalArgumentException
key
parameter using
the underlying system's MDC implementation. The key
parameter
cannot be null. This method does nothing if there is no previous value
associated with key
.
IllegalArgumentException
- in case the "key" parameter is nullpublic static void clear()
public static MDCAdapter getMDCAdapter()
|
SLF4J API Version 1.4.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |