什么是get4urrentLoggers在log4j2中的模拟 [英] What is getCurrentLoggers's analog in log4j2

查看:222
本文介绍了什么是get4urrentLoggers在log4j2中的模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取log4j2中使用的所有记录器?在log4j中我可以使用如下所述的getCurrentLoggers:使用的记录器数量

How can i get all loggers used used in log4j2? In log4j i could use getCurrentLoggers like described here: Number of loggers used

推荐答案

看起来我找到了方法:

File configFile = new File("c:\\my_path\\log4j2.xml");
LoggerContext loggerContext = Configurator.initialize("my_config", null, configFile.toURI());
Configuration configuration = loggerContext.getConfiguration();
Collection<LoggerConfig> loggerConfigs = configuration.getLoggers().values();

这篇关于什么是get4urrentLoggers在log4j2中的模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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