Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-624

MDC Adapter with configurable InheritableThreadLocal

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.9.28
    • Fix Version/s: 1.1.5
    • Component/s: logback-classic
    • Labels:
      None

      Description

      In our application we use a sifting file appender to log bot requests to a different log file than normal user requests. We have several sensor and aggregation threads that are started on different times that also have some logging output.

      My Problem:
      Log statements from request-independent threads are posted to bot.log and main.log on random.

      My Solution:
      I patched the LogbackMDCAdapter to be configureable by a system variable, to disable inheritance of the thread local member "copyOnInheritThreadLocal".
      The patched version defaults to old behavior, so it doesn't change if you do not configure it.
      To disable inheritance of that member, just pass "logback.threadlocal.inherit.copy=false" to the JVM.

      I applied the patch to Version 0.9.28 and tested it with our application. Maybe other logback users also want to configure logback in that way.

        Attachments

          Activity

            People

            • Assignee:
              logback-dev Logback dev list
              Reporter:
              treptow Alexander Treptow
            • Votes:
              15 Vote for this issue
              Watchers:
              18 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: