views:

550

answers:

2

Which setting do I now use to produce logging output 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'
}
+1  A: 

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

Jared
I expanded my initial question so the complete list of items I have set for the log4j configuration is part of the question. These are the defaults as generated by grails create-app. The part I added was my domain class root under 'info'.
Robin Jamieson
You'll still need to do what Jared says. Currently <code>'org.codehaus.groovy.grails.web.servlet'</code> is set as error (the default). You need to manually change that to info.
Matt Lachman
+2  A: 

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
}
Robin Jamieson