in log4j-jakarta-web/src/main/java/org/apache/logging/log4j/web/Log4jServletContextListener.java [71:94]
public void contextInitialized(final ServletContextEvent event) {
this.servletContext = event.getServletContext();
if ("true".equalsIgnoreCase(servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_AUTO_SHUTDOWN_DISABLED))) {
throw new IllegalStateException("Do not use " + getClass().getSimpleName() + " when "
+ Log4jWebSupport.IS_LOG4J_AUTO_SHUTDOWN_DISABLED + " is true. Please use "
+ Log4jShutdownOnContextDestroyedListener.class.getSimpleName() + " instead of "
+ getClass().getSimpleName() + ".");
}
this.initializer = WebLoggerContextUtils.getWebLifeCycle(this.servletContext);
if (getAndIncrementCount() != 0) {
LOGGER.debug(
"Skipping Log4j context initialization, since {} is registered multiple times.",
getClass().getSimpleName());
return;
}
LOGGER.info("{} triggered a Log4j context initialization.", getClass().getSimpleName());
try {
this.initializer.start();
this.initializer.setLoggerContext(); // the application is just now starting to start up
} catch (final IllegalStateException e) {
throw new IllegalStateException("Failed to initialize Log4j properly.", e);
}
}