Testing 在集成测试期间登录Grails
在执行集成测试时,我一直在努力让日志消息显示出来(无论是文件还是控制台)。我假设可以使用以下代码添加日志消息:Testing 在集成测试期间登录Grails,testing,grails,log4j,integration,Testing,Grails,Log4j,Integration,在执行集成测试时,我一直在努力让日志消息显示出来(无论是文件还是控制台)。我假设可以使用以下代码添加日志消息: log.debug "Some useful information here" 我在\u GrailsWar.groovy中注释掉了以下几行: target(startLogging:"Bootstraps logging") { // do nothing, overrides default behaviour so that logging doesn't kick in
log.debug "Some useful information here"
我在\u GrailsWar.groovy
中注释掉了以下几行:
target(startLogging:"Bootstraps logging") {
// do nothing, overrides default behaviour so that logging doesn't kick in
}
正如这里所建议的
Config.groovy
的log4j部分如下所示:
// 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
}
}
有人知道为什么我在集成测试期间看不到日志消息吗
非常感谢您抽出时间。查看用户邮件列表。你可能正在经历什么
编辑:嗯,很可能你已经这么做了,对不起。我终于找到了解决我自己问题的办法。为了进行登录集成测试,我在顶部附近添加了以下行:
import org.apache.commons.logging.LogFactory
然后在课堂上我添加了以下内容:
def log = LogFactory.getLog(getClass())
这是来自:
然后我可以做日志记录,比如
log.debug('*** It works! ***');
谢谢你的建议。我没有看到您提到的特定邮件列表,尽管我看到了其中的链接,该链接建议修改_GrailsWar.groovy文件。不幸的是,我无法从线程中找到解决方案。