Translate Basic Config.groovy log4j DSL to external log4j.properties

Posted by Stephen Swensen on Stack Overflow See other posts from Stack Overflow or by Stephen Swensen
Published on 2010-06-15T21:11:16Z Indexed on 2010/06/15 21:12 UTC
Read the original article Hit count: 861

Filed under:
|
|

The following is a basic log4j configuration inside Config.groovy using the log4j DSL with Grails 1.2, it works as expected (log all errors to the given file):

log4j = {
    appenders {
        file name:'file', file:"c:/error.log"
    }

    error 'grails.app'

    root {
        error 'file'
    }
}

How would one translate this into a properties style log4j configuration file? The following does not work:

log4j.rootLogger=ERROR, FA

log4j.appender.FA=org.apache.log4j.FileAppender
log4j.appender.FA.File=C:/error.log

log4j.logger.grails.app=ERROR, FA

I suspect it has something to do with the translation of error 'grails.app' but I really don't know.

If it makes any difference, the properties file is configured externally:

grails.config.locations = ["file:${basedir}/extconf/log4j.properties"]

All I really want is an external log4j properties file which logs all application exceptions to a file.

© Stack Overflow or respective owner

Related posts about logging

Related posts about grails