Log4j2 中的日志管理器存在方法不起作用



Log4j2 中的LogManager.exists(loggerName)方法不起作用,因为它适用于 log4j1。 请告知执行相同任务的替代方法。

如果所需的记录器在 xml 中不可用,则需要登录默认文件

这是我

使用的替代方案:

LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
config.getLoggers().keySet().contains(loggerName);

最新更新