logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-467) Thread name caching in async logger incompatible with use of Thread.setName()
Date Sat, 04 Jan 2014 06:30:52 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Remko Popma updated LOG4J2-467:

    Attachment: PerfTestDriver.java

If you see "Logback..." you are not using the PerfTestDriver class attached to this Jira.
The attached PerfTestDriver has all tests commented out except the Log4J2 AsyncLogger test.

I've attached a new version of PerfTestDriver to this Jira that correctly passes command line
property -DAsyncLogger.ThreadNameStrategy=UNCACHED (or CACHED) to the actual test process.

To run this test:
* update log4j2 project from SVN
* replace  {{log4j2/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java}}
with the file attached to this Jira
* build with {{mvn clean install -DskipTests}}
* {{cd log4j2/log4j-core/target}}
* {{java -DAsyncLogger.ThreadNameStrategy=UNCACHED -cp .;log4j-core-2.0RC1-SNAPSHOT-tests.jar;log4j-core-2.0RC1-SNAPSHOT.jar;../../log4j-api/target/log4j-api-2.0RC1-SNAPSHOT.jar;test-classes;c:/users/remko/.m2/repository/com/lmax/disruptor/3.2.0/disruptor-3.2.0.jar
** (You probably need to modify the path to {{disruptor-3.2.0.jar}})

> Thread name caching in async logger incompatible with use of Thread.setName()
> -----------------------------------------------------------------------------
>                 Key: LOG4J2-467
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-467
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-beta9
>         Environment: Debian Squeeze amd64
> OpenJDK 7u25
>            Reporter: Anthony Baldocchi
>            Assignee: Remko Popma
>             Fix For: 2.0-rc1
>         Attachments: PerfTestDriver.java, PerfTestDriver.java
> 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

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message