Logging in Grails during Integration Testing

I've been struggling for hours trying to get logging messages displayed (either to a file or the console) when performing integration tests. I assumed I could use the following code to add a log message:

log.debug "Some useful information here"

I have commented out the following line in _GrailsWar.groovy:

target(startLogging:"Bootstraps logging") {
// do nothing, overrides default behaviour so that logging doesn't kick in    
}

as suggested here http://jira.codehaus.org/browse/GRAILS-4470

The log4j section of Config.groovy looks like this:

// log4j configuration
log4j = {
    // Example of changing the log pattern for the default console
    // appender:
    //
    appenders {
        //console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n
        //console name: 'stdout', layout: pattern(conversionPattern: '%d{dd-MM-yyyy HH:mm:ss,SSS} %5p %c{1} - %m%n')
        //file name: 'hibeFile', file: 'hibe.log', layout: pattern(conversionPattern: '%d{dd-MM-yyyy HH:mm:ss,SSS} %5p %c{1} - %m%n')
        file name:'file', file:'C:/Users/Christopher/Documents/NetBeansProjects/TestProject/smyh.log', append: false
        console name:'stdout'
    }

    error  'org.codehaus.groovy.grails.web.servlet',  //  controllers
           'org.codehaus.groovy.grails.web.pages', //  GSP
           'org.codehaus.groovy.grails.web.sitemesh', //  layouts
           'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
           'org.codehaus.groovy.grails.web.mapping', // URL mapping
           'org.codehaus.groovy.grails.commons', // core / classloading
           'org.codehaus.groovy.grails.plugins', // plugins
           'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
           'org.springframework',
           'org.hibernate',
           'net.sf.ehcache.hibernate'

    warn   'org.mortbay.log'

    debug 'grails.app'

    info 'grails.app'

    root {
      // change the root logger to my tomcatLog file
      error 'file', stdout
      info 'file', stdout
      warn 'file', stdout
      debug 'file', stdout
      additivity = true
    }

}

Does anyone know why I can't see my log messages during integration tests?

Many thanks for your time.

5
задан Chris Claxton 3 January 2011 в 16:54
поделиться