[
https://issues.apache.org/jira/browse/LOG4J2-493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13868670#comment-13868670
]
Remko Popma commented on LOG4J2-493:
------------------------------------
Kireet,
I will think about how to solve this with AsyncLogger.
Meanwhile, can you try if one of these two workarounds solves the problem?
* Package the log4j2 jars with your web applications (and remove them from
$catalina.home/lib). Using the webapp classloader instead of the shared
classloader should solve the problem.
* Instead of making all loggers Asynchronous with the {{Log4jContextSelector}}
system property, use [mixed sync and async
loggers|http://logging.apache.org/log4j/2.x/manual/async.html#MixedSync-Async].
In the log4j2.xml configuration for your apps, replace {{root}} by
{{AsyncRoot}} and {{logger}} by {{AsyncLogger}} elements. (Don't forget to
remove the {{Log4jContextSelector}} system property setting.) Mixed sync/async
logging has a different implementation that should not suffer from the problem
you describe.
> NPE in AsyncLogger.shutdown
> ---------------------------
>
> Key: LOG4J2-493
> URL: https://issues.apache.org/jira/browse/LOG4J2-493
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0-beta9
> Environment: tomcat 7.0.42
> Reporter: Kireet Reddy
>
> When redeploying my application in tomcat multiple times, I get an exception:
> Exception in thread "Thread-29" java.lang.NullPointerException
> at
> org.apache.logging.log4j.core.async.AsyncLogger.stop(AsyncLogger.java:249)
> at
> org.apache.logging.log4j.core.async.AsyncLoggerContext.stop(AsyncLoggerContext.java:56)
> at
> org.apache.logging.log4j.core.LoggerContext$ShutdownThread.run(LoggerContext.java:437)
> This seems to be due to the fact that some initialization code happens in the
> class initializer but is undone in the stop() method which is called during
> webapp undeployment. This causes issues because in this case the log4j jar is
> loaded by the shared classloader ($catalina.home/lib) rather than the webapp
> classloader. This means the AsyncLogger class is not re-created during webapp
> deployment.
> I am using this structure because I have many 3rd party libraries and want to
> keep redeployments lightweight.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]