Class 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 normal InheritableThreadLocal child 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 Detail

      • PaxContext

        public PaxContext()
    • 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.
      • setContextMap

        public void setContextMap​(Map<String,​Object> contextMap)
        Sets all values from passed map in this thread-bound MDC context. This methods always clears existing values first.
        Parameters:
        contextMap -