public final class MDC
extends java.lang.Object
NDC class except that it is based on a map instead of a stack. It provides
mapped diagnostic contexts. A Mapped Diagnostic Context, or MDC in short, is an instrument for
distinguishing interleaved log output from different sources. Log output is typically interleaved when a server
handles multiple clients near-simultaneously.
The MDC is managed on a per thread basis. A child thread automatically inherits a copy of the mapped diagnostic context of its parent.
The MDC class requires JDK 1.2 or above. Under JDK 1.1 the MDC will always return empty values but otherwise will not affect or harm your application.
| Modifier and Type | Method | Description |
|---|---|---|
static void |
clear() |
Remove all values from the MDC.
|
static java.lang.Object |
get(java.lang.String key) |
Get the context identified by the
key parameter. |
static java.util.Hashtable |
getContext() |
Get the current thread's MDC as a hashtable.
|
static void |
put(java.lang.String key,
java.lang.Object value) |
Put a context value (the
o parameter) as identified with the key parameter into the current
thread's context map. |
static void |
remove(java.lang.String key) |
Remove the the context identified by the
key parameter. |
public static java.util.Hashtable getContext()
public static java.lang.Object get(java.lang.String key)
key parameter.
This method has no side effects.
key - Key parameter of context valuepublic static void put(java.lang.String key,
java.lang.Object value)
o parameter) as identified with the key parameter into the current
thread's context map.
If the current thread does not have a context map it is created as a side effect.
key - Key parameter of context valuevalue - Context valuepublic static void remove(java.lang.String key)
key parameter.key - Key of parameter to removepublic static void clear()
Copyright © 2019. All rights reserved.