【问题标题】:LogManager exists method in Log4j2 is not workingLog4j2 中的 LogManager 存在方法不起作用
【发布时间】:2018-08-10 01:49:52
【问题描述】:

Log4j2 中的LogManager.exists(loggerName) 方法无法正常工作,因为它适用于 log4j1。请建议执行相同任务的替代方法。

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

【问题讨论】:

    标签: logging log4j log4j2 apache-commons-logging


    【解决方案1】:

    这是我使用的替代方法:

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

    【讨论】:

      猜你喜欢
      • 2014-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      • 2015-01-02
      • 2018-03-15
      相关资源
      最近更新 更多