grailsloggingconsolespringsource

grails log messages not displaying on STS 3.0 console


I am using Grails 2.1 bundled with the SpringSource's Groovy/Grails Tool Suite 3.0 and have been unsuccessful in getting log messages to display in the console window. I have set the following in the config.groovy
log4j = {
info 'grails.app.controller'
}

However when I use the following line in a controller it does not display in the console

log.info " Hello World!"

Any comments are tips would be welcome. Thanks


Solution

  • I believe this is because you haven't invoked the appender for the console.

    You can do it like:

    log4j = {
        appenders {
            console name: "stdout", threshold: org.apache.log4j.Level.INFO
        }
    }
    

    You can also specify custom patterns using the layout setting:

    log4j = {
        appenders {
            console name: "stdout",
                    layout: pattern(conversionPattern: "%c{2} %m%n")
        }
    }
    

    Ref: Grails Logging