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

Thomas Beauvais edited comment on LOG4J2-2110 at 11/19/17 9:43 PM:
-------------------------------------------------------------------

Tomcat is calling {{onStartup}} and if you look, the only thing that was 
changed is getting the {{Log4jServletContextListener}} a reference to the 
{{servletContext}} in order to call the cleanup on {{contextDestroyed}} which 
doesn't happen in the current implementation since it's null.

We have tested this with a based web application w/ a custom appender on Tomcat 
8.0, 8.5 and 9.0. All show that the {{onStartup}} is called, yet without 
providing the servlet context to the listener (for later reference in the 
aforementioned {{contextDestroyed}}). Also, by design, the 
{{contextInitialized}} is never called. This is why you can see similar code 
shared between the two classes.


was (Author: thomas.beauvais):
Tomcat is calling `onStartup` and if you look, the only thing that was changed 
is getting the `Log4jServletContextListener` a reference to the 
`servletContext` in order to call the cleanup on `contextDestroyed` which 
doesn't happen in the current implementation since it's null.

We have tested this with a based web application w/ a custom appender on Tomcat 
8.0, 8.5 and 9.0. All show that the `onStartup` is called, yet without 
providing the servlet context to the listener (for later reference in the 
aforementioned `contextDestroyed`). Also, by design, the `contextInitialized` 
is never called. This is why you can see similar code shared between the two 
classes.

> Log4jServletContextListener skips initialization and thusly never calls stop()
> ------------------------------------------------------------------------------
>
>                 Key: LOG4J2-2110
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2110
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Web/Servlet
>    Affects Versions: 2.8, 2.8.1, 2.8.2, 2.9.0, 2.9.1
>            Reporter: Thomas Beauvais
>            Priority: Critical
>
> {{Log4jServletContextListener}} is not working in Tomcat 8 or 8.5 as it's 
> never initialized. 
> The {{contextInitialized}} is never called and thus it never sets the 
> {{servletContext}}.
> This is checked when a {{servletContext}} is destroyed and ignored every time.
> The outcome, is that our customer appenders are never stopped leading to 
> resource leaks.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to