我想将我的日志存储到文件中: 以下是我在 Config.groovy 中声明附加程序的方式:
log4j = {
appenders {
// console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
file name: "scraperServiceDetailedLogger",
file: "target/scraperServiceDetailed.log"
file name: "scraperServiceLogger",
file: "target/scraperService.log"
file name: "filterLogger",
file: "target/filter.log"
}
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'
error scraperServiceDetailedLogger: "grails.app.service.personalcreditcomparator.ScraperService"
info scraperServiceLogger: "grails.app.jobs.personalcreditcomparator.ScraperJob"
info filterLogger: "grails.app.conf.personalcreditcomparator.AdministratorInterfaceProtectorFilters"
}
这 3 个文件已正确创建,但只有 scraperServiceDetailedLogger
正确存储日志。另外两个文件仍为空。
调用日志
时会考虑日志记录级别。
我错过了什么?
感谢您提供的任何帮助。
最佳答案
对于quartz作业,请尝试使用“grails.app.task”的Logger前缀
info scraperServiceLogger: "grails.app.task.personalcreditcomparator.ScraperJob"
对于过滤器,尝试使用 Logger 前缀“grails.app.filters”
info filterLogger: "grails.app.filters.personalcreditcomparator.AdministratorInterfaceProtectorFilters"
关于file - Grails - 从 Quartz 作业和过滤器记录日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7288655/