我想根据模块登录到不同的附加程序...
我有 3 个附加程序:控制台、一个用于记录控制器和服务的滚动文件,以及另一个用于在作业中记录一些内容的滚动文件。我只想为它的滚动文件记录作业的代码,并只用另一个滚动文件记录控制器和服务。
所以这是我的 grails log4j 配置:
development {
def catalinaBase = System.properties.getProperty('catalina.base')
if (!catalinaBase) catalinaBase = '.'
def logDirectory = "${catalinaBase}/logs/AmbienticWebsite"
log4j = {
appenders {
console name:'stdout', layout:pattern(conversionPattern: '%c{2} [%p] - %m%n')
appender new DailyRollingFileAppender(
name: "rollingFileGrailsApp",
file: "${logDirectory}/GrailsApp.log",
datePattern: "'.'yyyy-MM-dd",
layout: pattern(conversionPattern: commonPattern)
)
appender new DailyRollingFileAppender(
name: "rollingFileImport",
file: "${logDirectory}/Imports.log",
datePattern: "'.'yyyy-MM-dd",
layout: pattern(conversionPattern: commonPattern)
)
}
root {
error 'stdout', 'rollingFileImport', 'rollingFileGrailsApp' // both stdout and AmbienticWebsite_dev.log are filled by logging information
additivity = false
}
debug rollingFileImport: 'ambienticwebsite.EventImportJob',
'time2marketing.time2marketingImportService',
'eventImportData.DiscomImportDataService',
'eventImportData.EventImportService'
info rollingFileGrailsApp: 'ambienticwebsite',
'ambienticwebsite.jobManagement.AmbienticJobListener',
'BootStrap',
'grails.app.controllers',
'grails.app.services'
}
}
使用此配置,日志将写入两个滚动文件和标准输出。如果我从根目录中删除滚动附加程序,滚动文件将保持为空,即使为文件组指定了附加程序。
有没有人建议将日志分成附加程序?