logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LOG4J2-493) Problem with AsyncLogger when web app is deployed/undeployed multiple times
Date Fri, 23 Oct 2015 17:19:27 GMT

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

Remko Popma edited comment on LOG4J2-493 at 10/23/15 5:18 PM:
--------------------------------------------------------------

I created branch LOG4J2-493-AsyncLogger-webapps to work on a solution for this issue. 
* AsyncLoggerContext is no longer a singleton: each web app will have a separate AsyncLoggerContext
associated with it, so starting/stopping a web app will not affect the logger contexts of
other web apps
* AsyncLoggerHelper static fields are now normal instance fields: each Helper instance (and
thus each AsyncLoggerContext) will have a separate Disruptor instance that is started/stopped
together with the web app
* AsyncLoggerContextSelector now subclasses ClassLoaderContextSelector

Initial test results: with log4j2.xml and all log4j2 jars in $catalina.home/lib, multiple
web apps can now be restarted and logging no longer breaks.


was (Author: remkop@yahoo.com):
I created branch LOG4J2-493-AsyncLogger-webapps to work on a solution for this issue. 
* AsyncLoggerHelper static fields are now normal instance fields
* AsyncLoggerContext is no longer a singleton
* AsyncLoggerContextSelector now manages multiple AsyncLoggerContext instances, in a map keyed
on the hashCode of the specified ClassLoader. 

TODO implement logic for case where currentContext=true

Initial test results are encouraging: with log4j2.xml and all log4j2 jars in $catalina.home/lib,
multiple web apps can now be restarted and logging no longer breaks.

> Problem with AsyncLogger when web app is deployed/undeployed multiple times
> ---------------------------------------------------------------------------
>
>                 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, 2.0-rc1
>         Environment: tomcat 7.0.42
>            Reporter: Kireet Reddy
>            Assignee: Remko Popma
>              Labels: Async
>             Fix For: 2.5
>
>
> |_This ticket tracks Async Logger issues in Tomcat when making all loggers async with
LoggerContextSelector system property. For Tomcat issues with AsyncRoot/AsyncLogger in the
configuration file, see LOG4J2-323._|
> When redeploying my application in tomcat multiple times, I get an exception:
> {code}
> 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)
> {code}
> 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.3.4#6332)

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


Mime
View raw message