问题描述
我想配置Grails log4j根据控制器将日志存储在不同的文件中。
I would like configure Grails log4j to store logs in different files depending of the controller.
所以,我有一个package.Controller1和package.Controller2。
在controller1上,我希望以debug模式存储在logfile1.logs和controller2上的logfile2.logs。
So, I have a package.Controller1 and package.Controller2 .On controller1, I would like store in logfile1.logs and on controller2 on logfile2.logs in debug mode.
如何做到这一点?
谢谢。
推荐答案
创建appender作为文件(或rollingFile等等):
Create the appenders as file (or rollingFile etc.):
appenders {
file name: "logfile1", file: "/path/to/logfile1.logs"
file name: "logfile2", file: "/path/to/logfile2.logs"
}
,然后使用Map语法将两个控制器分成独立的appender:
and then use the Map syntax to partition the two controllers into separate appenders:
debug logfile1: "grails.app.controller.package.Controller1",
logfile2: "grails.app.controller.package.Controller2"
请参阅以获取更多详细信息。
See http://docs.grails.org/latest/guide/conf.html#logging for more details.
这篇关于Grails和Log4J:如何登录同一级别的不同文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!