English 中文(简体)
Grails 1.1 and how to info level logging
原标题:

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 
}
最佳回答

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





相关问题
grails + gwt request handling via controllers

I am new to gwt. I am trying to integrate gwt+grails.Can anybody provide me a good example for handling the request using grails controllers and not a custom servlet.I will be really thankful if ...

Error loading the grails gwt module xml

I ve installed the plugin from this article by Peter http://www.cacoethes.co.uk/blog/groovyandgrails/the-command-pattern-w.... While compile time its not able to find the module file which is present ...

Sorting Objects Based on Custom Domain Class Methods

I have a domain class, in which I ve defined some methods which give the object a score based on different algorithms (eg. popularity). I now want to retrieve a list of these objects sorted by one of ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

Hibernate/GORM: collection was not processed by flush()

I have an integration test in my Grails application that fails when I try to save an entity of type Member invitingMember.save(flush: true) This raises the following exception org.hibernate....

热门标签