【问题标题】:In Grails 3.1.x, how do I configure grails logging to include the class name in the logging statement?在 Grails 3.1.x 中,如何配置 grails 日志记录以在日志记录语句中包含类名?
【发布时间】:2017-03-21 08:30:14
【问题描述】:

被打印的类是记录器的类,而不是包含日志语句的类。

logback 模式:

pattern = "%date{ISO8601} [%level] %class{100} %msg%n"

在 MyController.class 中调用记录器:

log.info("Some message);

结果

2017-03-21 19:06:50,824 [INFO] org.apache.commons.logging.Log$Log$info$0 Some message

Play 框架中有一个非常相似的问题,但解决方案是 Play 特定的: https://stackoverflow.com/a/28820410/258896

我尝试显式获取记录器,但它对输出没有任何影响。

static Logger log = LoggerFactory.getLogger(MyController.class)

使用:

Grails 3.1.14

【问题讨论】:

    标签: grails logback grails-3.1 apache-commons-logging


    【解决方案1】:

    试试:

    pattern = "%date{ISO8601} [%level] %logger{0} %msg%n"
    

    括号中的值说明here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-07
      • 2011-02-24
      • 2014-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-12
      相关资源
      最近更新 更多