How to properly shutdown log4j2

前端 未结 3 990
轻奢々
轻奢々 2020-12-06 10:36

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

3条回答
  •  清歌不尽
    2020-12-06 11:19

    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().

提交回复
热议问题