Log4j Logger垃圾回收? [英] Log4j Logger garbage collection?

查看:90
本文介绍了Log4j Logger垃圾回收?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以强制释放Log4j Logger/回收垃圾?

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

通常,Log4j是否会挂起"某些static集合中的Logger引用?

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

我看到了Logger.shutdown()方法,该方法已被弃用,并引用了LoggerManager.shutdown(),这听起来并不像它解决了单个Logger实例.

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.

推荐答案

您可以自己查看log4j源代码.

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

基于快速拖网,我认为答案是:

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

有没有办法强制Log4j Logger释放/收集垃圾?

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

不具有这种粒度级别.我唯一能找到的是释放所有记录器的方法(Heirarchy.clear()),并破坏了该过程中的记录层次结构.

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.

通常,Log4j是否挂起"某些静态集合中的Logger引用?

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

是的.而且该集合不使用弱引用...

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

这篇关于Log4j Logger垃圾回收?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆