[ 
https://issues.apache.org/jira/browse/LOG4J2-1259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15510324#comment-15510324
 ] 

Gabriel Stanek commented on LOG4J2-1259:
----------------------------------------

My test so far have not been successful.  I've used the following dependencies:
{code:xml}
                <dependency>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-api</artifactId>
                        <version>2.6.3-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-core</artifactId>
                        <version>2.6.3-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-slf4j-impl</artifactId>
                        <version>2.6.2</version>
                </dependency>
                <dependency>
                        <groupId>org.slf4j</groupId> 
                        <artifactId>slf4j-api</artifactId>
                        <version>1.7.21</version>
                </dependency>
                <dependency>
                        <groupId>com.lmax</groupId>
                        <artifactId>disruptor</artifactId>
                        <version>3.3.5</version>
                </dependency>
{code}

but, when I delete my war to undeploy the app, I see the following:

{code:xml}
Sep 21, 2016 8:37:30 AM org.apache.catalina.startup.HostConfig undeploy
INFO: Undeploying context [/webs-pub-subscription-usage-api]
Sep 21, 2016 8:37:30 AM org.apache.catalina.loader.WebappClassLoader 
clearReferencesJdbc
SEVERE: The web application [/webs-pub-subscription-usage-api] registered the 
JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web 
application was stopped. To prevent a memory leak, the JDBC Driver has been 
forcibly unregistered.
Sep 21, 2016 8:37:30 AM org.apache.catalina.loader.WebappClassLoader 
clearReferencesThreads
SEVERE: The web application [/webs-pub-subscription-usage-api] appears to have 
started a thread named [Log4j2-TF-3-Scheduled-1] but has failed to stop it. 
This is very likely to create a memory leak.
Sep 21, 2016 8:37:30 AM org.apache.catalina.loader.WebappClassLoader 
clearReferencesThreads
SEVERE: The web application [/webs-pub-subscription-usage-api] appears to have 
started a thread named [Log4j2-TF-4-AsyncLoggerConfig-2] but has failed to stop 
it. This is very likely to create a memory leak.
Sep 21, 2016 8:37:30 AM org.apache.catalina.loader.WebappClassLoader 
clearReferencesThreads
SEVERE: The web application [/webs-pub-subscription-usage-api] appears to have 
started a thread named [Thread-53] but has failed to stop it. This is very 
likely to create a memory leak.
Sep 21, 2016 8:37:30 AM org.apache.catalina.loader.WebappClassLoader 
checkThreadLocalMapForLeaks
SEVERE: The web application [/webs-pub-subscription-usage-api] created a 
ThreadLocal with key of type [org.springframework.core.NamedThreadLocal] (value 
[Locale context]) and a value of type 
[org.springframework.context.i18n.SimpleLocaleContext] (value [en_US]) 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.
Sep 21, 2016 8:37:30 AM org.apache.catalina.loader.WebappClassLoader 
checkThreadLocalMapForLeaks
SEVERE: The web application [/webs-pub-subscription-usage-api] created a 
ThreadLocal with key of type [com.intuit.platform.webs.aop.KpiLogging$1] (value 
[com.intuit.platform.webs.aop.KpiLogging$1@20cec9a5]) and a value of type 
[java.util.HashMap] (value [{}]) 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.
Sep 21, 2016 8:37:45 AM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.  
Could not load 
org.apache.logging.log4j.core.config.ConfiguratonFileWatcher$ReconfigurationWorker.
  The eventual following stack trace is caused by an error thrown for debugging 
purposes as well as to attempt to terminate the thread which caused the illegal 
access, and has no functional impact.
java.lang.IllegalStateException
        at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1614)
        at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1573)
        at 
org.apache.logging.log4j.core.config.ConfiguratonFileWatcher.fileModified(ConfiguratonFileWatcher.java:46)
        at 
org.apache.logging.log4j.core.util.WatchManager$WatchWorker.run(WatchManager.java:103)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
        at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
        at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
{code}

For reference, my log4j2.xml configuration is the following:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration strict="true" name="loggingConfig" monitorInterval="30">
        <Properties>
                <Property name="logDir">${sys:catalina.base}/logs</Property>
                <Property 
name="fileName">webs-pub-subscription-usage-api-v3.log</Property>
        </Properties>
        <Appenders>
                <RollingRandomAccessFile name="fileLogger"
                        fileName="${logDir}/${fileName}" append="true"
                        
filePattern="${logDir}/$${date:yyyy-MM}/${fileName}-%d{MM-dd-yyyy}-%i.log.gz">
                        <PatternLayout>
                                <pattern>%d | level=%-5p| thread=%t | class=%c 
|%X{intuit_app_nameFormat}%X{intuit_appidFormat}%X{intuit_assetaliasFormat}%X{intuit_originatingipFormat}%X{intuit_tidFormat}%X{intuit_transactionidFormat}%X{intuit_realmidFormat}%X{intuit_subscriptionidFormat}%X{intuit_useridFormat}
 %m%n</pattern>
                        </PatternLayout>
                        <Policies>
                                <TimeBasedTriggeringPolicy />
                                <SizeBasedTriggeringPolicy size="250 MB" />
                        </Policies>
                        <DefaultRolloverStrategy max="10" />
                </RollingRandomAccessFile>
        </Appenders>
        <Loggers>
                <AsyncRoot level="INFO" additivity="false">
                        <AppenderRef ref="fileLogger" />
                </AsyncRoot>
        </Loggers>
</Configuration>
{code}

If you see that I have configured something incorrectly, I'd be happy to make a 
change and test again.


> Log4j threads are leaking on Tomcat shutdown
> --------------------------------------------
>
>                 Key: LOG4J2-1259
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1259
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.5
>            Reporter: Misagh Moayyed
>
> Running log4j2 v2.5 with disruptor 3.3.x. AsyncLoggers configured. log4j-web 
> also included in the web application deployed in Tomcat 8. The context 
> listener is correctly starting up and shutting down, catalina.properties does 
> not include the log4j*.jar entry. Yet I see:
> {code}
> 20-Jan-2016 14:59:26.322 WARNING [localhost-startStop-2] 
> org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The 
> web application [cas-server-webapp-4.3.0-SNAPSHOT] appears to have started a 
> thread named [Log4j2-Log4j2Scheduled-5] but has failed to stop it. This is 
> very likely to create a memory leak. Stack trace of thread:
>  sun.misc.Unsafe.park(Native Method)
>  java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
>  
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
>  
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
>  
> java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
>  java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
>  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
>  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>  java.lang.Thread.run(Thread.java:745)
> 20-Jan-2016 14:59:26.336 WARNING [localhost-startStop-2] 
> org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The 
> web application [cas-server-webapp-4.3.0-SNAPSHOT] appears to have started a 
> thread named [Log4j2-AsyncLoggerConfig-6] but has failed to stop it. This is 
> very likely to create a memory leak. Stack trace of thread:
>  sun.misc.Unsafe.park(Native Method)
>  java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
>  
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
>  com.lmax.disruptor.BlockingWaitStrategy.waitFor(BlockingWaitStrategy.java:45)
>  
> com.lmax.disruptor.ProcessingSequenceBarrier.waitFor(ProcessingSequenceBarrier.java:56)
>  com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:124)
>  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>  java.lang.Thread.run(Thread.java:745)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to