Log4j似乎忽略了我在Config.groovy中的一些Grails Logging设置,但没有忽略其他设置。我在tomcat上运行Grails 2.2.1。
我已经设置了我的配置文件(下面),将所有错误和更高的消息记录到控制台(映射到tomcat中的catalina.out),解析,调度和联合包中的所有信息和更高的消息master.log,并且所有调试解析,调度和联合包中的更高消息到它们各自的解析,调度和联合日志。
appenders部分中提到的所有文件都是在适当的位置创建的,并且正在接收日志消息。但是, master.log正在接收调试消息,并且当配置明确将它们限制为25MB时,master.log和syndicate.log都增长到19GB 。
谁能看到我做错了什么? grails如何尊重我的配置的一行而不是下一行呢?我的Config.groovy文件的相关部分是:
log4j = {
// Uncomment to override the default logging level across all
// classes.
root {
warn catalinaOut
}
appenders {
// this line prevents all messages from being duplicated to stdout DONT DELETE
console name: "stdout",
layout: pattern(conversionPattern: "")
console name: "catalinaOut",
layout: pattern(conversionPattern: "%-5p [%d] %c{2} %m%n")
file name: "dcsFileAppender",
file: "logs/data-collection-system/master.log",
maxFileSize: "25MB",in
maxBackupIndex: 10,
layout: pattern(conversionPattern: "%-5p [%d] %c{2} %m%n")
file name: "parseFileAppender",
file: "logs/data-collection-system/parse.log",
maxFileSize: "25MB",
maxBackupIndex: 10,
layout: pattern(conversionPattern: "%-5p [%d] %c{2} %m%n")
file name: "scheduleFileAppender",
file: "logs/data-collection-system/schedule.log",
maxFileSize: "25MB",
maxBackupIndex: 10,
layout: pattern(conversionPattern: "%-5p [%d] %c{2} %m%n")
file name: "syndicateFileAppender",
file: "logs/data-collection-system/syndicate.log",
maxFileSize: "25MB",
maxBackupIndex: 10,
layout: pattern(conversionPattern: "%-5p [%d] %c{2} %m%n")
}
environments {
production {
info dcsFileAppender: ["com.progauge.icp.parse", "com.progauge.icp.schedule", "com.progauge.icp.syndicate"]
all parseFileAppender: ["com.progauge.icp.parse"],
scheduleFileAppender: ["com.progauge.icp.schedule"],
syndicateFileAppender: ["com.progauge.icp.syndicate"]
}
}
}
作为旁注,我不得不将stdout的模式设置为空字符串,因为我不想要标准的控制台日志记录行为,但是将appender设置为null会破坏我的自定义控制台日志记录,这也是我不想要的。
答案 0 :(得分:3)
到目前为止,我看到了配置的三个主要问题:
rollingFile
类型的追加程序而不是file
stdout
的默认'null'
appender(这是四个字符串null而不是null
值,并定义一个Log4J NullAppender
,忽略写入其中的任何日志消息的接收器。)尝试更像这样的事情:
log4j = {
// Uncomment to override the default logging level across all
// classes.
root {
warn 'catalinaOut'
}
appenders {
// this line prevents all messages from being duplicated to stdout
'null' name: "stdout"
console name: "catalinaOut",
layout: pattern(conversionPattern: "%-5p [%d] %c{2} %m%n")
// threshold to make this appender only log INFO and higher messages
rollingFile name: "dcsFileAppender",
file: "logs/data-collection-system/master.log",
maxFileSize: "25MB",
maxBackupIndex: 10,
layout: pattern(conversionPattern: "%-5p [%d] %c{2} %m%n"),
threshold: org.apache.log4j.Level.INFO
rollingFile name: "parseFileAppender",
file: "logs/data-collection-system/parse.log",
maxFileSize: "25MB",
maxBackupIndex: 10,
layout: pattern(conversionPattern: "%-5p [%d] %c{2} %m%n")
rollingFile name: "scheduleFileAppender",
file: "logs/data-collection-system/schedule.log",
maxFileSize: "25MB",
maxBackupIndex: 10,
layout: pattern(conversionPattern: "%-5p [%d] %c{2} %m%n")
rollingFile name: "syndicateFileAppender",
file: "logs/data-collection-system/syndicate.log",
maxFileSize: "25MB",
maxBackupIndex: 10,
layout: pattern(conversionPattern: "%-5p [%d] %c{2} %m%n")
}
environments {
production {
all parseFileAppender: ["com.progauge.icp.parse"],
scheduleFileAppender: ["com.progauge.icp.schedule"],
syndicateFileAppender: ["com.progauge.icp.syndicate"],
dcsFileAppender: ["com.progauge.icp.parse", "com.progauge.icp.schedule", "com.progauge.icp.syndicate"]
}
}
}