logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nick Williams (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-223) IllegalStateException thrown during Tomcat shutdown
Date Sun, 19 May 2013 17:09:15 GMT

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

Nick Williams commented on LOG4J2-223:
--------------------------------------

I don't think the hook _has_ to be able to be enabled/disabled. {{Log4jContextListener}} calls
{{stop()}} on the {{LoggerContext}}, and {{stop()}} removes the shutdown hook. So, used this
way, the shutdown hook isn't a problem, it just isn't used. That's why everything's okay when
using the {{BasicContextSelector}}. (I'm not saying it's a _bad_ idea to provide way to enable/disable
the shutdown hook. It wouldn't hurt.)

So here are the philosophical or real issues that need to be resolved/answered, from my perspective:

# Why does {{BasicContextSelector}} work and {{ClassLoaderContextSelector}} not work in a
web application when a {{Log4jContextListener}} is properly used?
# Is there any way to make logging "just work" in a web application without creating a listener
and/or filter? I'm starting to become convinced that there isn't, and that disappoints me.
# Would {{Log4jContextListener}} and {{JNDIContextFilter}} ever both be used at the same time,
and would doing that cause a malfunction?

Assuming the ultimate conclusion is that logging can't "just work" in a web application and
a listener/filter is required, I would like to drastically simplify usage of the log4j-web
module. My thoughts on it are:
# There should only be a listener, not a filter.
# There should be no init parameters; everything should be automatic and follow normal Log4j
conventions.
# There should be a {{META-INF/web-fragment.xml}} file that creates the filter automatically
so that if the user is using a Servlet 3.0 or newer container he doesn't even have to consciously
create the filter, he just has to include the JAR.
# It should be in the Core module, so that it works automatically in web applications.

I make these arguments because, here I am, a committer on the project and an avid reader of
the documentation, and I still had no idea the {{Log4jContextListener}} and/or {{JNDIContextFilter}}
were required to make logging work properly in a web application.
                
> IllegalStateException thrown during Tomcat shutdown
> ---------------------------------------------------
>
>                 Key: LOG4J2-223
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-223
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-beta5
>            Reporter: Ralph Goers
>            Priority: Critical
>             Fix For: 2.0-beta7
>
>         Attachments: log4j-223.war
>
>
> {noformat}Apr 25, 2013 3:03:33 PM org.apache.catalina.core.StandardServer await
> INFO: A valid shutdown command was received via the shutdown port. Stopping the Server
instance.
> Apr 25, 2013 3:03:33 PM org.apache.coyote.AbstractProtocol pause
> INFO: Pausing ProtocolHandler ["http-nio-8080"]
> Apr 25, 2013 3:03:33 PM org.apache.coyote.AbstractProtocol pause
> INFO: Pausing ProtocolHandler ["ajp-nio-8009"]
> Apr 25, 2013 3:03:33 PM org.apache.catalina.core.StandardService stopInternal
> INFO: Stopping service Catalina
> Apr 25, 2013 3:03:33 PM org.apache.coyote.AbstractProtocol stop
> INFO: Stopping ProtocolHandler ["http-nio-8080"]
> Apr 25, 2013 3:03:33 PM org.apache.coyote.AbstractProtocol stop
> INFO: Stopping ProtocolHandler ["ajp-nio-8009"]
> Apr 25, 2013 3:03:33 PM org.apache.coyote.AbstractProtocol destroy
> INFO: Destroying ProtocolHandler ["http-nio-8080"]
> Apr 25, 2013 3:03:33 PM org.apache.coyote.AbstractProtocol destroy
> INFO: Destroying ProtocolHandler ["ajp-nio-8009"]
> Apr 25, 2013 3:03:33 PM 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.NullConfiguration.  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:1351)
> 	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1310)
> 	at org.apache.logging.log4j.core.LoggerContext.stop(LoggerContext.java:171)
> 	at org.apache.logging.log4j.core.LoggerContext$ShutdownThread.run(LoggerContext.java:389)
> Exception in thread "Thread-18" java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/config/NullConfiguration
> 	at org.apache.logging.log4j.core.LoggerContext.stop(LoggerContext.java:171)
> 	at org.apache.logging.log4j.core.LoggerContext$ShutdownThread.run(LoggerContext.java:389)
> Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.core.config.NullConfiguration
> 	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1465)
> 	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1310)
> 	... 2 more{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
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