Class ContextMapLookup

java.lang.Object
org.apache.logging.log4j.core.lookup.ContextMapLookup
All Implemented Interfaces:
StrLookup

@Plugin(name="ctx", category="Lookup") public class ContextMapLookup extends Object implements StrLookup
Looks up keys from the context. By default this is the ThreadContext, but users may configure a custom ContextDataInjector which obtains context data from some other source.
  • Constructor Details

    • ContextMapLookup

      public ContextMapLookup()
  • Method Details

    • lookup

      public String lookup(String key)
      Looks up the value from the ThreadContext Map.
      Specified by:
      lookup in interface StrLookup
      Parameters:
      key - the key to be looked up, may be null
      Returns:
      The value associated with the key.
    • lookup

      public String lookup(LogEvent event, String key)
      Looks up the value from the ThreadContext Map.
      Specified by:
      lookup in interface StrLookup
      Parameters:
      event - The current LogEvent.
      key - the key to be looked up, may be null
      Returns:
      The value associated with the key.