Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1611

Improve performance of ThreadContextDataInjector.ForDefaultThreadContextMap

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7
    • 2.7
    • Core
    • None

    Description

      Current implementation of ThreadContextDataInjector.ForDefaultThreadContextMap::injectContextData always copies all elements from the ThreadContext into the reused StringMap of the LogEvent.

      Since the DefaultThreadContextMap is used in web applications (when non-JDK thread-locals are not available and Log4j is not garbage-free), we don't need to worry about creating additional objects. We can speed up the injectContextData method by wrapping the context data Map<String, String> in a decorator object that implements the StringMap interface.

      Attachments

        1. InjectWithoutProperties.png
          36 kB
          Remko Popma
        2. InjectWithProperties.png
          41 kB
          Remko Popma
        3. ThreadContext-Get.png
          30 kB
          Remko Popma
        4. ThreadContext-PutAndRemove.png
          34 kB
          Remko Popma

        Issue Links

          Activity

            People

              rpopma Remko Popma
              rpopma Remko Popma
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: