We have spring 3.0.x based appl开发者_如何学编程ication, we use SimpleMappingExceptionResolver which sends emails on an exception, when the exception happens within the DispatcherServlet.
This gives us following flexibility:
- Subject can include who the logged in user is, so that we can send personalized email to the user
- Subject also includes the server on which the error occurred
- The request params, request url, and headers -- helped us find some problems when search engine indexing the site.
However, lately we have been finding the exceptions have been occurring in the filters, and since this is not going through the Resolver, we dont get any emails.
The log4j email appenedr solution is very restrictive, subject is not dynamic, doesnot know the user who is logged in. We just think that Filter is for request processing, having a filter hijack the response on Exception, might cause unwanted results. Atleast this is our view. Please feel free to comment otherwise.
Is there an accepted pattern to resolve this issue.
Edited: We dont like the log4j email appender solution, and not writing another filter to send emails seems right.
精彩评论