Log4j Logger garbage collection?

半世苍凉 提交于 2020-01-06 15:51:37

问题


Is there a way to force a Log4j Logger to be released/garbage collected?

In general, does Log4j "hang on" to Logger references in some static collection?

I see the Logger.shutdown() method, which is deprecated and refers to LoggerManager.shutdown(), which doesn't sound like it addresses a single Logger instance.


回答1:


You could take a look at the log4j source code yourself.

Based on a quick trawl, I think the answers are:

Is there a way to force a Log4j Logger to be released/garbage collected?

Not with that level of granularity. The only thing I could find was a method (Heirarchy.clear()) that releases all loggers ... and destroy the logging hierarchy in the process.

In general, does Log4j "hang on" to Logger references in some static collection?

Yes. And the collection doesn't use weak references ...



来源:https://stackoverflow.com/questions/11581997/log4j-logger-garbage-collection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!