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

Thread name caching in async logger incompatible with use of Thread.setName()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-beta9
    • 2.0-rc1, 2.0
    • Core
    • None
    • Debian Squeeze amd64
      OpenJDK 7u25

    Description

      AsyncLogger caches a thread's name in a thread-local info variable. I make use of a thread pool where the submitted Runnables call Thread.setName() at the beginning of their task and the thread name is included in the log message. For an example of this behavior, see org.jboss.netty.util.ThreadRenamingRunnable in Netty 3.x. With the cached thread name, the log messages will contain whatever name the thread had when it logged for the first time and so long as the thread doesn't terminate (such as in a core pool thread), all log messages involving this thread will be erroneous. If Thread.getName has a significant performance impact for async logging, I would be satisfied if this behavior were configurable, perhaps on a per-logger basis, so that the penalty only needs to be taken by users who make use of Thread.setName()

      Attachments

        1. PerfTestDriver.java
          16 kB
          Remko Popma
        2. PerfTestDriver.java
          15 kB
          Remko Popma

        Issue Links

          Activity

            People

              rpopma Remko Popma
              abaldocchi Anthony Baldocchi
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: