I have the following log4j config in my Grails 1.1 app
log4j = {
// Enable Hibernate SQL logging with param values
trace 'org.hibernate.type'
debug 'org.hibernate.SQL'
debug 'com.mycompany'
appenders {
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')
}
// By default, messages are logged at the error level to both the console and hibe.log
root {
error 'stdout', 'hibeFile'
additivity = true
}
}
When I run unit tests, the only logging output generated is from the Hibernate classes. I don't understand why no logging output is generated for my own classes, i.e. those under the com.mycompany
namespace. Strangely, when I run integration tests, the log4j output is as expected.
If I go to the test report for a unit test, and click on the "System.out" link, I see my log messages in the following format:
DEBUG (member.InviteServiceTests): Calling getInvite with member (4517)
Notice that this is not the same pattern as that which I've specified in my log4j configuration. Furthermore, if I change the log4j config from:
debug 'com.mycompany'
to:
fatal 'com.mycompany'
I still see log messages at the debug level in the test report. It seems as though the root logger is being overriden when running unit tests? I've tried logging classes under com.mycompany
using a separate logger, but this doesn't seem to make any difference
Thanks, Don