How to properly shutdown log4j2

user671731 picture user671731 · Sep 16, 2014 · Viewed 13.1k times · Source

If one is not running inside a web application, what is the proper way to shutdown Log4j2? I only see a noop LogManager.shutdown()

Answer

Remko Popma picture Remko Popma · Sep 17, 2014

There is no public API for this, but you can use

((LifeCycle) LogManager.getContext()).stop();

If you have an interest in having a public API for this, please vote for or add a comment here: https://issues.apache.org/jira/browse/LOG4J2-124


Update:

In Log4j 2.5 you can call Configurator.shutdown(). With Log4j 2.6 you can call LogManager.shutdown().