java - Log4j2 - ThreadLocal memory leak in ServletContextListener -


i following error when shutting down tomcat :

severe: web application [app] created threadlocal key of type [org.apache.logging.log4j.core.layout.patternlayout$1] (value [org.apache.logging.log4j.core.layout.patternlayout$1@14391aaf]) , value of type [java.lang.stringbuilder] (value [2015-09-30 14:22:27.832 [localhost-startstop-1] error applogger - error log. ]) failed remove when web application stopped. threads going renewed on time try , avoid probable memory leak.

it appears if try log inside contextinitialized or contextdestroyed method in servletcontextlistener implementation. logging works fine in rest of app once tomcat has started. noticed value of stringbuilder last entry logged. in case, following code generates log :

@override public void contextinitialized(servletcontextevent arg0) {     logger logger = logmanager.getlogger("applogger");     logger.error("error log."); } 

after several hours of investigation (including so), still can't find explanation. log4j2 initialization problem? bug should report?

i'm using tomcat 8.0 in eclipse 4.5

log4j-core-2.4, log4j-api-2.4, log4j-web-2.4 in classpath.

web.xml in 'web-inf'

<web-app xmlns="http://java.sun.com/xml/ns/javaee"    xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"    xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"    version="3.0">  <context-param>     <param-name>log4jcontextname</param-name>     <param-value>app</param-value> </context-param>  </web-app> 

log4j2.xml in 'src'

<?xml version="1.0" encoding="utf-8"?> <configuration> <!-- http://logging.apache.org/log4j/2.x/manual/configuration.html --> <appenders>     <file name="file" filename="/home/user/app.log">         <patternlayout pattern="%d{yyy-mm-dd hh:mm:ss.sss} [%t] %-5level %logger{36} - %msg%n"/>     </file>     <console name="console">         <patternlayout pattern="%d{yyy-mm-dd hh:mm:ss.sss} [%t] %-5level %logger{36} - %msg%n"/>     </console> </appenders> <loggers>     <logger name="applogger" level="all">         <appenderref ref="file"/>     </logger>     <root level="all">         <appenderref ref="console"/>     </root> </loggers> </configuration> 

this related threadlocal introduced in log4j 2.4. discovered after release , will fixed in next release, either 2.4.1 or 2.5 (we hope soon, in week or two).


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -