Hello, I have a problem with shutting down log4j2 in a Java EE environment, which does not include servlets. Currently my code for shutting down log4j2 is located in a Singleton Startup Bean in a @PreDestroy annotated method.
@PreDestroy public static void shutDown() { LogManager.shutdown(); } This did not work however. It looks like the log4j is shutting down only to be started up again. This restart prevents our application from undeploying, leaving all the loaded classes on the server. My current assumption is the restart happens, because of something in our application is calling LogManager.getLogger(clazz) after LogManager.shutdown() is called. Therefore we came up with this workaround: @PreDestroy public static void shutDown() { org.apache.logging.log4j.LogManager.shutdown(); Configurator.reconfigure(new NullConfiguration()); Server.unregisterMBeans(); } It prevents the instantiation of the appenders and async loggers and replacing the current config with a NullConfiguration. The restart still takes place, but it does not prevent the undeplyoment any more (when getting rid of existing MBeans). Is there a more elegant solution, maybe getting rid of the restart in the first place? Best regards Rene Schindler ________________________________ This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.