问题:
值得注意的是:
答案 0 :(得分:7)
解决方案是将以下内容添加到Config.groovy的log4j部分:
log4j = {
...
appenders {
console name:'stdout', layout:pattern(conversionPattern: '[%r] %c{2} %m%n')
if (grails.util.Environment.current == grails.util.Environment.PRODUCTION) {
def patternLayout = new org.apache.log4j.PatternLayout()
patternLayout.setConversionPattern("[%r] %c{2} %m%n")
def mailAppender = new org.apache.log4j.net.SMTPAppender()
mailAppender.setFrom("from@example.com")
mailAppender.setTo("to@example.com")
mailAppender.setSubject("An log4j error has been generated in the production environment")
mailAppender.setSMTPHost("your-smtp-host")
mailAppender.setLayout(patternLayout)
appender name:'mail', mailAppender
}
}
root {
error 'stdout', 'mail'
additivity = true
}
...
}
另外将sun-javamail.jar和activation.jar添加到lib / -folder。
此配置已经过测试,可按预期工作。