You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enable WARN logging with DefaultHandlerExceptionResolver #2176
Currently if an exception such as MissingServletRequestParameterException is thrown no stack-trace is logged. It would be useful to provide an option to add them.
@wilkinsona@dsyer Any thoughts about this? Trying to debug #2162 highlighted the problem. Not sure if we should enable by default because the logs could get pretty full just by people posting incomplete data.
Tricky one. On the one hand, it could be used as a form of DoS attack if you managed to flood the logs with exception messages. On the other hand, it'd make problem diagnosis easier.
I could be convinced either way but perhaps we should err toward secure by default and default to off?
I'm not familiar enough with the internals of the MVC chain post-controller to say whether mine is a duplicate, but they're semantically related. This one seems to be dealing with resolving controller arguments, and mine is about exceptions thrown after the controller has returned an argument during JSON/XML serialization.
Let's assume I have added a @ResponseStatus annotation on a custom exception, here's what I get for a single call to the service that throws that exception:
Your proposal above does not work as MVC ships with 3 "default" resolvers and that default is the fallback. Spring MVC logs the exception even if the handler does not ultimately resolve the model (that's what happens with ExceptionHandlerExceptionResolver).
Long story short:
Enabling only DefaultHandlerExceptionResolver looks incomplete to me: there are two other implementations before this one that have a chance to resolve the exception
Enabling all 3 defaults can easily lead to duplicate warning log
Exception has been correctly processed by ExceptionHandler. What's the point to log it? What's the point to log it at WARN level? What's the point to enable it by default?
Reacted by Kacper Stolc, Yangshifu, Ted Sjöblom, Orderpoints, Vazgen Torosyan , Alexander Riss, Rüdiger Schulz, moonshine, Aaron Nwabuoku, F. Andy seidl and 3 more
When I have ControllerAdvice and have method anotated with ExceptionHandler and I'm doing redirect ExceptionHandlerExceptionResolver logs with WARN level.
Why?
I already handled custom exception and logged it
ExceptionHandlerExceptionResolver is part of Spring Framework. If you have a question about it, please ask on Stack Overflow. If you have a suggestion for an improvement, please open a JIRA ticket.
@TorosyanV I have same issue and having to fix by setting log level to ERROR. I wonder if you found a better way. org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: ERROR
Activity
philwebb commentedon Dec 16, 2014
@wilkinsona @dsyer Any thoughts about this? Trying to debug #2162 highlighted the problem. Not sure if we should enable by default because the logs could get pretty full just by people posting incomplete data.
wilkinsona commentedon Dec 16, 2014
Tricky one. On the one hand, it could be used as a form of DoS attack if you managed to flood the logs with exception messages. On the other hand, it'd make problem diagnosis easier.
I could be convinced either way but perhaps we should err toward secure by default and default to off?
philwebb commentedon Dec 16, 2014
Moving to 1.3. Could be another good candidate to enable during development but not in production.
chrylis commentedon Jan 14, 2015
I'm not familiar enough with the internals of the MVC chain post-controller to say whether mine is a duplicate, but they're semantically related. This one seems to be dealing with resolving controller arguments, and mine is about exceptions thrown after the controller has returned an argument during JSON/XML serialization.
Enable logging of resolved exceptions
snicoll commentedon May 24, 2016
@philwebb I gave that a try, you can find a proposal (see snicoll@745671a)
Let's assume I have added a
@ResponseStatusannotation on a custom exception, here's what I get for a single call to the service that throws that exception:Your proposal above does not work as MVC ships with 3 "default" resolvers and that default is the fallback. Spring MVC logs the exception even if the handler does not ultimately resolve the model (that's what happens with
ExceptionHandlerExceptionResolver).Long story short:
DefaultHandlerExceptionResolverlooks incomplete to me: there are two other implementations before this one that have a chance to resolve the exceptionThoughts?
celiovasconcelos commentedon Jun 8, 2016
Tested in 1.3.5.RELEASE
I was forced to workaround like this:
Otherwise, no way to see my custom exception in the log.
bclozel commentedon Jun 23, 2016
SPR-14392 has been fixed.
You should now get a single WARN log when the exception is actually resolved, like this:
@snicoll I think you can now merge your proposal.
fedotxxl commentedon Nov 8, 2017
Exception has been correctly processed by ExceptionHandler. What's the point to log it? What's the point to log it at WARN level? What's the point to enable it by default?
TorosyanV commentedon Oct 3, 2018
When I have ControllerAdvice and have method anotated with ExceptionHandler and I'm doing redirect ExceptionHandlerExceptionResolver logs with WARN level.
Why?
I already handled custom exception and logged it
wilkinsona commentedon Oct 3, 2018
ExceptionHandlerExceptionResolveris part of Spring Framework. If you have a question about it, please ask on Stack Overflow. If you have a suggestion for an improvement, please open a JIRA ticket.MSMTFaro commentedon Nov 5, 2018
@TorosyanV I have same issue and having to fix by setting log level to ERROR. I wonder if you found a better way.
org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: ERROR