Package org.ops4j.pax.logging
Class PaxContext
- java.lang.Object
-
- org.ops4j.pax.logging.PaxContext
-
public class PaxContext extends Object
The MDC class that 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 (with normalInheritableThreadLocalchild inherits the same references). That behavior can be switched off by setting the system property org.ops4j.pax.logging.threadContextMapInheritable to false (default is true). 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.- Since:
- 1.2
- Author:
- Ceki Gülcü
-
-
Constructor Summary
Constructors Constructor Description PaxContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears entire thread-bound MDC context.Objectget(String key)Gets a value from this thread-bound MDC context.Map<String,Object>getContext()Gets full map of values related to this thread-bound MDC context.Map<String,Object>getCopyOfContextMap()Gets a copy of full map of calues related to this thread-bound MDC context.voidput(String key, Object o)Sets single value in this thread-bound MDC context.voidputAll(Map<String,Object> context)Sets all values from passed map in this thread-bound MDC context.voidremove(String key)Removes a value from this thread-bound MDC context.voidsetContextMap(Map<String,Object> contextMap)Sets all values from passed map in this thread-bound MDC context.
-
-
-
Method Detail
-
putAll
public void putAll(Map<String,Object> context)
Sets all values from passed map in this thread-bound MDC context. This methods preserves existing values.- Parameters:
context-
-
put
public void put(String key, Object o)
Sets single value in this thread-bound MDC context.- Parameters:
key-o-
-
get
public Object get(String key)
Gets a value from this thread-bound MDC context.- Parameters:
key-- Returns:
-
remove
public void remove(String key)
Removes a value from this thread-bound MDC context.- Parameters:
key-
-
getContext
public Map<String,Object> getContext()
Gets full map of values related to this thread-bound MDC context.- Returns:
-
getCopyOfContextMap
public Map<String,Object> getCopyOfContextMap()
Gets a copy of full map of calues related to this thread-bound MDC context.- Returns:
-
clear
public void clear()
Clears entire thread-bound MDC context.
-
-