Grails 1.1 and how to info level logging
Which setting do I now use to produce logging 开发者_如何学JAVAoutput with 'log.info' statements within my own controllers?
Here's what I've setup in config.groovy and I thought placing my domain under the info level would do the trick but it doesn't. Neither does placing the groovy.grails.web.* packages under info section..
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'
warn 'org.mortbay.log'
info 'com.mydomain.someproject'
}
It turns out that I also need to add 'grails.app' to my info section:
info 'grails.app', // Logging warnings and higher for all of the app
My configuration looks more like this now:
log4j = {
info 'grails.app', // Logging warnings and higher for all of the app
'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
warn 'org.mortbay.log'
error 'org.codehaus.groovy.grails.commons', // core classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework', // spring framework
'org.hibernate' // hibernate framework
}
You have to tell grails what you want it to specifically log. You can't log a specific class Hierarchy. For example you would use the following to log controllers.
info 'org.codehaus.groovy.grails.web.servlet', // controllers
You could set your root logger to log at the info level but you would get everything including Hibernate. For info on what you can log see section 3.21 of the grails manual at this link. http://grails.org/doc/1.1.x/guide/3.%20Configuration.html#3.1.2%20Logging
精彩评论