How do I configure logging for a grails plugin?

2020-02-13 09:15发布

I'm creating my first grails plugin and I don't know where the logging should be configured.
In a normal grails app, there is a conf/Config.groovy file for that, but for a plugin there is none.
Is there another way to achieve this ?
I would like to see debug messages when I launch my plugin unit and integration tests...

Thanks in advance.
Philippe

1条回答
不美不萌又怎样
2楼-- · 2020-02-13 10:01

The create-plugin script doesn't create a Config.groovy but if you create one yourself it will be used. Don't copy one from an existing app since it'll be cluttered with stuff that isn't applicable, just create a log4j closure and whatever other properties you need:

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'
}

myplugin.someproperty = 'foo'
查看更多
登录 后发表回答