|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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 underlying system does not support MDC, e.g. java.util.logging,
then SLF4J will use a BasicMDCAdapter
.
Thus, as a SLF4J user, you can take advantage of MDC in the presence of log4j logback, or java.util.logging, but without forcing these systems 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 Map |
getCopyOfContextMap()
Return a copy of the current thread's context map, with keys and values of type String. |
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. |
static void |
setContextMap(Map contextMap)
Set the current thread's context map by first clearing any existing map and then copying the map passed as parameter. |
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 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 Map getCopyOfContextMap()
public static void setContextMap(Map contextMap)
contextMap
- must contain only keys and values of type Stringpublic static MDCAdapter getMDCAdapter()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |