Grails 日志记录 - 只记录我的应用程序,不记录 Grails 特定的垃圾
从默认日志记录配置开始,我添加了 root{} 块以打开调试级别日志记录。我为我的控制器添加了一个方法...
log4j = {
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'
warn 'org.mortbay.log'
debug 'grails.app.controller'
root {
debug()
}
}
现在我可以正常调试了。但我从各地得到它。 Grails 在执行运行应用程序、清除缓存、加载 spring bean 等时经历的所有启动垃圾。我想对其进行配置,以便我获得的唯一日志记录来自我的代码。这可能吗?
Starting from the default logging config, I added the root{} block to turn on debug level logging. And I added a method for my controllers...
log4j = {
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'
warn 'org.mortbay.log'
debug 'grails.app.controller'
root {
debug()
}
}
And now I get debug alright. But I get it from everywhere. All the startup junk that Grails goes through when doing a run-app, clearing cache, loading spring beans, etc. I want to configure this so the only logging I get is from my code. Is that even possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Config.groovy 文件的 log4j 部分中,定义一个日志附加程序,如下所示:
让根记录器成为根,并登录到控制台:
然后仅将调试添加到特定记录器中的应用程序
Grails 日志部分 已更改很多,但现在几乎是最新的。
In your Config.groovy file, in a log4j section, define a log appender like this:
Let the root logger be the root, and log on the console:
And then add debug only to your app in a specific logger
The grails Logging Section has been changing a lot, but is pretty much up to date now.