本文介绍了如何正确关闭log4j2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果没有在Web应用程序中运行,关闭Log4j2的正确方法是什么?我只看到一个Noop LogManager.shutdown()
If one is not running inside a web application, what is the proper way to shutdown Log4j2? I only see a noop LogManager.shutdown()
推荐答案
没有为此的公共API,但是您可以使用
There is no public API for this, but you can use
((LifeCycle) LogManager.getContext()).stop();
如果您有兴趣为此使用公共API,请在此处投票或添加评论: https://issues.apache.org/jira/browse/LOG4J2-124
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
更新:
在Log4j 2.5中,您可以调用Configurator.shutdown()
.使用Log4j 2.6,您可以调用LogManager.shutdown()
.
In Log4j 2.5 you can call Configurator.shutdown()
. With Log4j 2.6 you can call LogManager.shutdown()
.
这篇关于如何正确关闭log4j2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!