Class ThreadContextDataInjector.ForDefaultThreadContextMap

java.lang.Object
org.apache.logging.log4j.core.impl.ThreadContextDataInjector.ForDefaultThreadContextMap
All Implemented Interfaces:
ContextDataInjector
Enclosing class:
ThreadContextDataInjector

public static class ThreadContextDataInjector.ForDefaultThreadContextMap extends Object implements ContextDataInjector
Default ContextDataInjector for the legacy Map<String, String>-based ThreadContext (which is also the ThreadContext implementation used for web applications).

This injector always puts key-value pairs into the specified reusable StringMap.

  • Constructor Details

    • ForDefaultThreadContextMap

      public ForDefaultThreadContextMap()
  • Method Details

    • injectContextData

      public StringMap injectContextData(List<Property> props, StringMap ignore)
      Puts key-value pairs from both the specified list of properties as well as the thread context into the specified reusable StringMap.
      Specified by:
      injectContextData in interface ContextDataInjector
      Parameters:
      props - list of configuration properties, may be null
      ignore - a StringMap instance from the log event
      Returns:
      a StringMap combining configuration properties with thread context data
      See Also:
    • rawContextData

      public ReadOnlyStringMap rawContextData()
      Description copied from interface: ContextDataInjector
      Returns a ReadOnlyStringMap object reflecting the current state of the context. Configuration properties are not included in the result.

      This method may be called multiple times for each log event by Filters and Lookups and implementors should take care to make this method as performant as possible while preserving at least the following thread-safety guarantee.

      Thread-safety note: The returned object can only be safely used in the current thread. Changes in the underlying context may or may not be reflected in the returned object, depending on the context data source and the implementation of this method. It is not safe to pass the returned object to another thread.

      Specified by:
      rawContextData in interface ContextDataInjector
      Returns:
      a ReadOnlyStringMap object reflecting the current state of the context, may not return null