Logging from Bootstrap.groovy in Grails 3

With default configuration settings, calling code like log.info "Log message" in Bootstrap.groovy can be an exercise in frustration, or at least missing expected log output. Grails 3 uses the Logback library for configuring log output, and you can customize your configuration in the new logback.groovy file under grails-app/conf.

Fortunately the logback documentation is quite helpful, and the Groovy config DSL is simple to use and will be familiar to most Grails developers. Here's a simple logger configuration that will direct log messages from Bootstrap.groovy to your standard output:

logger('grails.app.init.BootStrap', INFO, ['STDOUT'], false)

Zachary Klein

Zachary Klein

I'm on the Grails Team at OCI. This blog is just a place to record tips or workarounds I've found useful while working with Groovy, Grails, Gradle, and associated oddities.