简体   繁体   中英

In Grails 3.1.x, how do I configure grails logging to include the class name in the logging statement?

The class that gets printed is the logger's class, not the class that contains the log statement.

logback pattern:

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

Calling logger in MyController.class:

log.info("Some message);

results in

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

There is a very similar problem in the Play framework, but the solution is Play specific: https://stackoverflow.com/a/28820410/258896

I tried to explicitly get the logger, but it made no difference in the output.

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

Using:

Grails 3.1.14

Try:

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

Explanation of value in brackets here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM