This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

MessageDispatcher - exception logging

Feb 20th, 2008, 02:41 PM

I have 2 kinds of exceptions returned from my service implementations:
1. unexpected exceptions (eg. NullPointerException), and
2. exceptions which are normal and expected outcomes of the business logic function (eg. NoMoreMoneyOnAccountException)
(I think this is a general pattern of using exceptions)

expected exceptions are handled by my custom ExceptionResolver
and unexpected exceptions are handled by the standard SimpleSoapExceptionResolver

"unexpected" exceptions should be logged at WARN (or ERROR) level
because they indicate some problem in the system

"expected" exceptions should either not be logged, or logged at DEBUG level
because they are normal and expected outcome of the business logic function, they do not indicate problem in the system

unfortunately the MessageDispatcher class (the processEndpointException() method) logs all exceptions at WARN level
and this can not easily be customized

shouldn't it be possible to customize somehow the exception logging functionality?
it is quite disturbing to have all the expected and normal exceptions being logged at WARN level

One approach is to do your own logging in the exception resolver. To make this easier, I set the log level from WARN to DEBUG, which seemed more appropriate and consistent with the Spring-MVC DispatcherServlet.