Description
Description
Shutdown of Log4j2 system initialized via org.apache.logging.log4j.web.Log4jServletContainerInitializer happens first before all ServletContextListener contextDestroyed methods are called in a servlet container (tomcat).
I would expect Log4j2 to shutdown itself at the very end, so other context listeners have the change to log something during their shutdown procedure.
If I intialize/shutdown log4j2 via org.apache.logging.log4j.web.Log4jServletContextListener and put the context listener at the very top in web.xml
then log4j2 properly shuts down after every other listener.
If I debug
if (!"true".equalsIgnoreCase(servletContext.getInitParameter(
Log4jWebSupport.IS_LOG4J_AUTO_SHUTDOWN_DISABLED))) {
servletContext.addListener(new Log4jServletContextListener());
}
in Log4jServletContainerInitializer, all other listener already exists in the servletContext and the Log4jServletContextListener is added to the very end, thus shutdown happens as the very first.
Configuration
Version: log4j2-web 2.20.0
Operating system: MacOS
JDK: JDK 11 Temurin
Servlet Container:: Tomcat 9.0.73
Logs
N/A