我的 grails config.groovy 中有这个 log4j 配置
log4j = {
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages' // GSP
warn 'org.mortbay.log'
appenders {
rollingFile name:'infoLog', file:'info.log', threshold: org.apache.log4j.Level.INFO, maxFileSize:1024
rollingFile name:'warnLog', file:'warn.log', threshold: org.apache.log4j.Level.WARN, maxFileSize:1024
rollingFile name:'errorLog', file:'error.log', threshold: org.apache.log4j.Level.ERROR, maxFileSize:1024
rollingFile name:'custom', file:'custom.log', maxFileSize:1024
}
root {
info 'infoLog','warnLog','errorLog','custom', stdout
error()
additivity = true
}
}
infoLog、warnLog 和 errorLog 来自上一个问题……它们运行良好。
现在我添加名为“custom”的新 RollingFile ...
我尝试使用 log.info("something .... ${obj}") 从我的 Controller 和服务中登录; 但似乎消息没有插入到 custom.log 中,我是否需要在配置中添加一些内容?
谢谢!!
最佳答案
刚从 grails 的邮件列表中得到答案:
我只需要添加
调试“grails.app”
下面警告“org.mortbay.log”
结案了! :)
关于java - grails 中的 log4j : how to log into file?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1157159/