Grails发送有关框架异常的电子邮件

nmy*_*nmy 0 grails groovy log4j exception-handling

在我的grails应用程序中,我发送有关例外的电子邮件.在我的UrlMappings.groovy.

"500"(controller: "error", action: "internalError")
Run Code Online (Sandbox Code Playgroud)

在我的internalError()方法中,ErrorController.groovy我使用MailService.groovy并发送异常细节.

现在我想发送类似的电子邮件,用于插件/框架中发生的异常,例如:hibernate,GORM,grails等

但问题是他们中的大多数已经通过try catch块处理并记录在插件中.例如 :

catch(Exception e){
    log.error("Error creating workbook", e)
}
Run Code Online (Sandbox Code Playgroud)

无论如何,我可以通过电子邮件发送此类例外吗?

这是我的log4j配置.

log4j.main = {
   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'
}
Run Code Online (Sandbox Code Playgroud)

小智 6

我会使用SMTPAppender通过电子邮件发送这些异常.