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. Grails 2 applications used Log4j 1. x. However, you should consider migrating as soon as possible to the latest version of the Grails framework.
Following the convention over configuration principle, Grails will configure any Groovy classes under grails-app/controllers/ as controllers, without any additional configuration. You can create the Groovy class yourself, or use the create-controller command to generate the controller and an associated test spec.
Grails removes the need to add configuration in XML files. Instead, the framework uses a set of rules or conventions while inspecting the code of Grails-based applications. For example, a class name that ends with Controller (for example BookController ) is considered a web controller.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With