[
https://issues.apache.org/jira/browse/LOG4J2-1172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Remko Popma resolved LOG4J2-1172.
---------------------------------
Resolution: Fixed
Fixed in master in commits 680eb6eb, a02bce46, f132f9ad, 908ae829, c9eff73f.
* Log4jWebInitializerImpl.start() now detects if the LoggerContext is an
AsyncLoggerContext, and if so,
signals the AsyncLoggerContext that it is used in a web app and should not
use custom ThreadLocals.
* Depending on whether the AsyncLoggerContext has been signalled to avoid
ThreadLocals or not,
AsyncLogger now either re-uses a per-thread RingBufferLogEventTranslator
instance (cached in a ThreadLocal),
or (for web apps) creates a new varargs object array for each event.
* Inner class AsyncLogger.Info has been removed.
* ThreadNameCachingStrategy is now a top-level class.
* The cached Thread name is stored in a ThreadLocal<String> in
ThreadNameCachingStrategy.
* NanoClock is now a non-static field in AsyncLogger.
* AsyncLogger is now responsible for updating the NanoClock when the
Configuration changes.
* Determining if the current thread is the background thread is now done by
comparing thread IDs, without requiring a ThreadLocal.
> ThreadLocal leak [AsyncLogger$Info] on Tomcat when using
> AsyncLoggerContextSelector
> -----------------------------------------------------------------------------------
>
> Key: LOG4J2-1172
> URL: https://issues.apache.org/jira/browse/LOG4J2-1172
> Project: Log4j 2
> Issue Type: Bug
> Components: Configurators, Web/Servlet
> Affects Versions: 2.4, 2.4.1, 2.5
> Reporter: Remko Popma
> Assignee: Remko Popma
> Fix For: 2.5
>
>
> Tomcat warns at SEVERE level about a ThreadLocal leak (AsyncLogger$Info).
> Steps to reproduce:
> * Make all loggers async by using the AsyncLoggerContextSelector
> * Place the log4j jar files in the web app's WEB-INF/lib folder, and the
> configuration file in the class path or in a location configured in the
> web.xml
> * Start the web app, trigger some logging, then stop the web app.
> Tomcat will warn
> {quote}
> SEVERE: The web application \[webapp] created a ThreadLocal with key of type
> \[org.apache.logging.log4j.core.async.AsyncLogger$Info$1] (value
> \[org.apache.logging.log4j.core.async.AsyncLogger$Info$1@136a1c9]) and a
> value of type \[org.apache.logging.log4j.core.async.AsyncLogger.Info] (value
> \[org.apache.logging.log4j.core.async.AsyncLogger$Info@597fb9]) but failed to
> remove it when the web application was stopped. Threads are going to be
> renewed over time to try and avoid a probable memory leak.
> {quote}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]