Configuring a Grails App for Logging

August 17, 2008 — Craig Jones

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.

Tags: , ,

Leave a Reply

Twitter Updates

  • On a mac it's super easy to encrypt/decrypt a file using openssl 2009-12-02
  • If you don’t think carefully, you might think that programming is just typing statements in a programming language. — Ward Cunningham 2009-12-01
  • Thanks to everyone at my CodeCamp LA presentation, you had great questions and I hope the exercise gave you something to take to work Monday 2009-11-21
  • Turns out my CodeCamp LA presentation made it to the front page of SlideShare today. Must be a slow day. 2009-11-21
  • Scrum has two deliverables, A Product Deliverable and a Capability Deliverable we don't talk up the second enough as agilists 2009-11-21
  • More updates...


Bad Behavior has blocked 59 access attempts in the last 7 days.