Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure logging for a grails plugin?

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

like image 971
Philippe Avatar asked May 27 '10 11:05

Philippe


People also ask

Does grails use Log4j?

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.

How do you make a controller on grails?

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.

How does Grails framework work?

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.


1 Answers

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'
like image 57
Burt Beckwith Avatar answered Sep 26 '22 05:09

Burt Beckwith