没有log4j的输出I具有以下log4j的配置在我的Grails 1.1应用Grails中应用
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
}
}
当运行单元测试,所产生的唯一的日志输出是从Hibernate类。我不明白为什么没有为我自己的类生成日志输出,即那些在com.mycompany
命名空间下的输出。奇怪的是,当我运行集成测试时,log4j输出如预期的那样。
如果我去测试报告的单元测试,并点击“的System.out”链接,我看到下面的格式我的日志消息:
DEBUG (member.InviteServiceTests): Calling getInvite with member (4517)
请注意,这不是与我在log4j配置中指定的模式相同。此外,如果我从改变log4j的配置:
debug 'com.mycompany'
到:
fatal 'com.mycompany'
我仍然看到在测试报告中的调试级别的日志信息。看起来好像根记录器在运行单元测试时被覆盖了?我使用一个单独的记录com.mycompany
下试过日志类,但是这似乎并没有什么差别
谢谢, 唐