【发布时间】:2012-03-09 10:57:10
【问题描述】:
我正在使用 Groovy 和 Log4J。 我不是 Log4J 专家,但在搜索了许多网站以寻找答案后,我认为我的配置应该可以在“Config.groovy”文件中使用。
结果如下: 我得到控制台日志记录。 但是,名为“project.log”和“StackTrace.log”的日志文件是空的。 我还创建了另一个名为“StackTrace.log.1”(2KB 大小)的文件,其中包含在我运行应用程序后发布的异常消息(非严重错误)。
问题: 为什么我没有在“project.log”和“StackTrace.log”文件中收到日志消息? 为什么会创建并写入名为“StackTrace.log.1”的文件,而不是将堆栈跟踪消息记录到“StackTrace.log”文件中?
任何关于我做错了什么的帮助或线索将不胜感激。
这是我的“Config.groovy”文件(log4j 部分):
// log4j configuration
log4j = {
// Set default level for all, unless overridden below.
root { debug 'stdout', 'file' }
// Set level for all application artifacts
info "grails.app"
error "org.hibernate.SQL", "org.hibernate.type"
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'
appenders {
rollingFile name: 'file', file:'project.log', maxFileSize:1024, append: true
rollingFile name: 'stacktrace', file: "StackTrace.log", maxFileSize: 1024, append: true
}
}
【问题讨论】: