使用Log4j,我们能够配置两个名为'stdout'的appender 'stacktrace'并将日志重定向到两个不同的文件。但是,只有 stdout似乎正在使用Logback插件。有谁知道如何获得 stacktrace还可以使用Logback吗?
例如(我也在grails邮件列表中发布了这个,但还没有收到任何回复):
logback = {
appenders {
rollingFile name: 'stdout', file: '/tmp/rolling.log',
encoder: pattern(pattern: '%-4relative [%thread] %-5level %logger{35} - %msg%n'),
triggeringPolicy: new SizeBasedTriggeringPolicy(maxFileSize: 10*1024*1024),
rollingPolicy: new FixedWindowRollingPolicy(fileNamePattern: '/tmp/rolling.%i.log.gz')
rollingFile name: 'stacktrace', file: '/tmp/rollingstacktrace.log',
encoder: pattern(pattern: '%-4relative [%thread] %-5level %logger{35} - %msg%n'),
triggeringPolicy: new SizeBasedTriggeringPolicy(maxFileSize: 10*1024*1024),
rollingPolicy: new FixedWindowRollingPolicy(fileNamePattern: '/tmp/rollingstacktrace.%i.log.gz')
}
//other logging code goes here...................
}
答案 0 :(得分:0)
这对我有用。你错过了进口吗?
import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy
import ch.qos.logback.core.rolling.FixedWindowRollingPolicy