Yu-Shan Fung <[email protected]> writes:
> Hi All,
>
> A bit of a shot in the dark, but is there an easy way to setup email
> notification on an lift app whenever an uncaught exception occurs? Seems
> like a common enough use-case, just wonder if there's a standard way to do
> it before I roll my own.
I have it setup so that all unhandled exceptions are logged with an
error:
private def setupGlobalErrorHandler() {
val currentHandler = LiftRules.exceptionHandler.toList.first
LiftRules.exceptionHandler.prepend {
case (Props.RunModes.Development, r, e) =>
Log.error("Exception occurred during processing of %s.
UserId=%s".format(r,User.currentUserId), e)
currentHandler((Props.RunModes.Development, r, e))
case (Props.RunModes.Production, r, e) =>
Log.error("Exception occurred during processing of %s.
UserId=%s".format(r,User.currentUserId), e)
RedirectResponse("/error.html")
}
}
}
I then (in production) configure logback to send me emails on errors:
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<SMTPHost>localhost</SMTPHost>
<To>x...@xxx</To>
<From>y...@fyyy</From>
<layout class="ch.qos.logback.classic.html.HTMLLayout" />
</appender>
/Jeppe
--
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en.