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

Improve performance of ThreadContextDataInjector.ForDefaultThreadContextMap

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7
    • Fix Version/s: 2.7
    • Component/s: Core
    • Labels:
      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

              • Assignee:
                remkop@yahoo.com Remko Popma
                Reporter:
                remkop@yahoo.com Remko Popma
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: