[ https://issues.apache.org/jira/browse/LOG4J2-2052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16177466#comment-16177466 ]
Remko Popma commented on LOG4J2-2052: ------------------------------------- Actually I just realized this can be as simple as {code} String defaultStrategy = System.getProperty("java.version"). compareTo("1.8.0_102") < 0 ? "CACHED" : "UNCACHED"; {code} in [ThreadNameCachingStrategy.create()|https://logging.apache.org/log4j/2.x/log4j-core/xref/org/apache/logging/log4j/core/async/ThreadNameCachingStrategy.html#L50]. > Disable thread name caching by default > -------------------------------------- > > Key: LOG4J2-2052 > URL: https://issues.apache.org/jira/browse/LOG4J2-2052 > Project: Log4j 2 > Issue Type: Improvement > Reporter: Dan Berindei > Assignee: Remko Popma > Priority: Minor > > We run our tests in parallel with TestNG and we use {{Thread.setName()}} for > easy filtering of log messages from a single test. But since LOG4J2-1334, all > the thread names are logged as {{TestNG}}, unless we use > {{-DAsyncLogger.ThreadNameStrategy=UNCACHED}}. > JDK 8u102 removed the {{String}} allocation in {{Thread.getName()}} > (https://bugs.openjdk.java.net/browse/JDK-8148842), so I suggest changing the > default strategy to {{UNCACHED}}. Users of older JDKs will still be able to > use {{-DAsyncLogger.ThreadNameStrategy=CACHED}} for the performance > improvement. -- This message was sent by Atlassian JIRA (v6.4.14#64029)