Disable Log4j2's shutdown hook by default
Previously, Log4j2's own shutdown hook was only disabled when Log4j2 detected javax.servlet.Servlet on the classpath and, therefore, determined that it was running in a web application. In an application without Servlet on the classpath, this could lead to both Log4j2's shut down hook and and logging system's shutdown handler both stopping Log4j2. This could result in a failure as the second attempt at stopping would result in reinitialization which would fail as the JVM is already shutting down. This commit introduces a new Log4j2 PropertySource implementation, registered via META-INF/services, that sets the log4j.shutdownHookEnabled property to false. This will ensure that Log4j2's own shutdown hook is disabled by default whenever Spring Boot is on the classpath and not just in Servlet-based web applications. Fixes gh-26953
Showing
Please register or sign in to comment