【发布时间】:2018-08-10 01:49:52
【问题描述】:
Log4j2 中的LogManager.exists(loggerName) 方法无法正常工作,因为它适用于 log4j1。请建议执行相同任务的替代方法。
如果所需的记录器在 xml 中不可用,则需要登录到默认文件
【问题讨论】:
标签: logging log4j log4j2 apache-commons-logging
Log4j2 中的LogManager.exists(loggerName) 方法无法正常工作,因为它适用于 log4j1。请建议执行相同任务的替代方法。
如果所需的记录器在 xml 中不可用,则需要登录到默认文件
【问题讨论】:
标签: logging log4j log4j2 apache-commons-logging
这是我使用的替代方法:
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
config.getLoggers().keySet().contains(loggerName);
【讨论】: