Configuring a Grails App for Logging

For any standard Grails app, the error log is called stacktrace.log by default. On some servers, it ends up in the config folder (rather than the logs folder) by default, so it’s hard to find. Also, with a fixed name, all apps running on the same server would share the same log. So, for any new Grails app, be sure to open Config.groovy and change

appender.'errors.File'="stacktrace.log"

to

appender.'errors.File'="../logs/${appName}-errors.log"

Determining What is Logged
Config.groovy also determines what is logged. The default logging level is error. For some packages, you’ll want to change the logging level to warn or info. Your choices are, in order: FATAL, ERROR, WARN, INFO, DEBUG.

Grails automatically generates a log4j.properties files from what’s in Config.groovy and places it in the /WEB-INF/classes folder. The log4j.properties file can be tweaked in place as you attempt to debug a particular problem, but just remember that it gets reset every time the app is deployed. So, permanent changes need to go in Config.groovy.



© 2006-2007 Maxim Software Corp.  All rights reserved.