来自Grails错误的Grails的电子邮件通知

Bud*_*Joe 6 grails

有没有办法在Grails网站上发生Grails错误时随时向我发送详细信息?设置它的最佳方法是什么?在一个地方?(试图保持干燥)

我想包含产生错误的URL.

Kus*_*khi 3

。如果您打算捕获项目上发生的任何异常并将其邮寄,那么我正在使用这样的设置,并且我按照以下方式做到了:

  1. 在 TagLib 中创建一个标签:

    def reportError = {attrs, body ->
            String error = body()
            //error will have the Error Details, you can mail this string :)
            //mail example
            mailService.mailError(error) //just an example
            //if you want to show the error on the error page
            out << error
            //if you want to show any custom message
            out << "Error mailed, check Email"
     }
    
    Run Code Online (Sandbox Code Playgroud)
  2. 在GSP页面views/error.gsp中将“ <g:renderException异常=”${exception}”/> ”标记替换为“ <myTagLib:reportError><g:renderException异常=”${exception}”/></ myTagLib:报告错误>

全做完了... :)

现在发生的情况是,每当发生异常时(即使在 AJAX 调用中),请求都会重定向到错误页面,我们可以在那里捕获所有错误。

此设置唯一不起作用的地方是未绑定到请求的执行的情况,即:JOBS。

在这种方法中,我能够捕获所有意外的异常:) ..

这就是我的做法,希望有帮助:)

问候库沙尔