使用的记录器数量 [英] Number of loggers used

查看:89
本文介绍了使用的记录器数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用log4j开发一个非常大的java应用程序,我想知道是否有办法在运行时提取活动记录器的数量?或者应用程序中现有的记录器是什么?
我的最终目标是获取所有记录器的列表并在运行时更改它们的级别。
谢谢。

I'm working on a very large java application with log4j, and I was wondering if there is a way to extract in runtime the number of active loggers? Or what are the existing loggers in the application? My end goal is to get a list of all loggers and change their level in runtime. Thank you.

推荐答案

您可以尝试类似:

Enumeration allLoggers = Logger.getRootLogger()
.getLoggerRepository()
.getCurrentLoggers();

然后迭代allLoggers。

Then iterate over allLoggers.

这篇关于使用的记录器数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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