Class Log4jv2ThreadContextMap

  • All Implemented Interfaces:
    org.apache.logging.log4j.spi.ThreadContextMap

    public class Log4jv2ThreadContextMap
    extends Object
    implements org.apache.logging.log4j.spi.ThreadContextMap
    The actual ThreadContext Map. A new ThreadContext Map is created each time it is updated and the Map stored is always immutable. This means the Map can be passed to other threads without concern that it will be updated. Since it is expected that the Map will be passed to many more log events than the number of keys it contains the performance should be much better than if the Map was copied for each event.
    • Constructor Detail

      • Log4jv2ThreadContextMap

        public Log4jv2ThreadContextMap()
    • Method Detail

      • put

        public void put​(String key,
                        String value)
        Specified by:
        put in interface org.apache.logging.log4j.spi.ThreadContextMap
      • get

        public String get​(String key)
        Specified by:
        get in interface org.apache.logging.log4j.spi.ThreadContextMap
      • remove

        public void remove​(String key)
        Specified by:
        remove in interface org.apache.logging.log4j.spi.ThreadContextMap
      • clear

        public void clear()
        Specified by:
        clear in interface org.apache.logging.log4j.spi.ThreadContextMap
      • containsKey

        public boolean containsKey​(String key)
        Specified by:
        containsKey in interface org.apache.logging.log4j.spi.ThreadContextMap
      • getCopy

        public Map<String,​String> getCopy()
        Specified by:
        getCopy in interface org.apache.logging.log4j.spi.ThreadContextMap
      • getImmutableMapOrNull

        public Map<String,​String> getImmutableMapOrNull()
        Specified by:
        getImmutableMapOrNull in interface org.apache.logging.log4j.spi.ThreadContextMap
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface org.apache.logging.log4j.spi.ThreadContextMap