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
InvocableHandlerMethod.getMethodArgumentValues() failure should lead to warn-level logging by default [SPR-13267] #17858
The InvocableHandlerMethod logs request mapping values at the TRACE and more recently the DEBUG levels when a request can't be mapped without issue.
We normally run Spring at LOG.warn to keep the log chattiness down. We were a bit thrown off on the issue until the Spring logging was dropped to the TRACE level. We will have external partner systems calling us in Production and we can't run Production at even a DEBUG level to troubleshoot these problems.
This is going to be an ongoing issue for our software solution.
InvocableHandlerMethod just logs a longer-winded message at debug level there, for a re-thrown exception that bubbles up the call stack eventually and will typically end up in the outermost Servlet exception handling (either in Spring MVC or in the Servlet container itself, depending on your configuration).
So I'm wondering: Are you afraid of not noticing an exception to begin with - despite it bubbling up to the Servlet level? Or are you asking for the more specific debug exception message to shine through? We could potentially wrap the root cause in some argument resolution exception with a fine-tuned message of ours...
We were only able to view the issue in the logs if we set the log level this way.
org.springframework.web.level=FINEST
( Note, this did not work:
org.springframework.web.method.support.InvocableHandlerMethod.level=FINEST )
You seem to be suggesting that the issue would be logged higher up in the stack, which we did not observe to be the case. Which class would you expect to log the request mapping issue as an error?
I was referring to those exceptions ending up at the outer Servlet level, with the Servlet container receiving a corresponding ServletException from the HttpServlet call that it initially triggered. This would then get written to the server log, not to the application's own log categories.
However, in Spring MVC specifically, a HandlerExceptionResolver may intercept an exception before it leaves the DispatcherServlet, rendering a custom error view or turning it into a custom HTTP status code. I suppose that this may be happening in your scenario? What exception class are you looking for specifically? Do you have a custom HandlerExceptionResolver configured? Are you using @ResponseStatus by any chance?
Ouch... I guess this about an HttpMessageNotReadableException coming out of an HttpMessageConverter, and in that case, our DefaultHandlerExceptionResolver will just send a status code 400 back but not perform any further logging. We will have to do something about that... probably not in InvocableHandlerMethod itself but rather in DefaultHandlerExceptionResolver.
My current solution is to log at warn level for all conversion exceptions in DefaultHandlerExceptionResolver, as a one-line entry with the exception type and message but no stacktrace. The full stacktrace would only be logged at debug level still, in order to avoid automatic escalations based on the presence of the stacktrace at warn level.
The logging of HTTP request processing failures is a rather complex affair. Bad requests - either incomplete or badly structured - may come frequently and commonly, so don't necessarily suggest an error or even warn-level situation for a public web API. At the same time, common server execution problems shouldn't remain unnoticed either.
Note that you can always implement your own HandlerExceptionResolver bean for your DispatcherServlet configuration (or an @ExceptionHandler method in your MVC controller) to provide your own exception handling, including warn or error level logging of your own. This is also the reason why we refrain from logging at warn or error level within Spring's processing infrastructure: In a custom exception handling scenario, such lower-level warn entries will be undesirable and cannot easily be suppressed. The configurable HandlerExceptionResolver mechanism provides a common point for enforcing such application-level exception handling policies at the very end of processing a specific request.
The changes above - DefaultHandlerExceptionResolver triggering warn log entries for conversion exceptions - will be available in the next 4.2.0.BUILD-SNAPSHOT. Feel free to give it an early try...
As mentioned, in particular with older versions of Spring, I'd recommend creating a custom HandlerExceptionResolver implementation (or DefaultHandlerExceptionResolver subclass) that logs at error or warn level as you see fit.
We need to stay on Spring 4.1.X for now. I was able to override the DefaultHandlerExceptionResolver and achieve the desired effect until we upgrade. Glad it's tweaked in 4.2.
Activity
spring-projects-issues commentedon Jul 27, 2015
Juergen Hoeller commented
InvocableHandlerMethodjust logs a longer-winded message at debug level there, for a re-thrown exception that bubbles up the call stack eventually and will typically end up in the outermost Servlet exception handling (either in Spring MVC or in the Servlet container itself, depending on your configuration).So I'm wondering: Are you afraid of not noticing an exception to begin with - despite it bubbling up to the Servlet level? Or are you asking for the more specific debug exception message to shine through? We could potentially wrap the root cause in some argument resolution exception with a fine-tuned message of ours...
Juergen
spring-projects-issues commentedon Jul 27, 2015
Steve Roy commented
We were only able to view the issue in the logs if we set the log level this way.
org.springframework.web.level=FINEST
( Note, this did not work:
org.springframework.web.method.support.InvocableHandlerMethod.level=FINEST )
You seem to be suggesting that the issue would be logged higher up in the stack, which we did not observe to be the case. Which class would you expect to log the request mapping issue as an error?
spring-projects-issues commentedon Jul 27, 2015
Juergen Hoeller commented
I was referring to those exceptions ending up at the outer Servlet level, with the Servlet container receiving a corresponding
ServletExceptionfrom theHttpServletcall that it initially triggered. This would then get written to the server log, not to the application's own log categories.However, in Spring MVC specifically, a
HandlerExceptionResolvermay intercept an exception before it leaves theDispatcherServlet, rendering a custom error view or turning it into a custom HTTP status code. I suppose that this may be happening in your scenario? What exception class are you looking for specifically? Do you have a customHandlerExceptionResolverconfigured? Are you using@ResponseStatusby any chance?Juergen
spring-projects-issues commentedon Jul 27, 2015
Juergen Hoeller commented
Ouch... I guess this about an
HttpMessageNotReadableExceptioncoming out of anHttpMessageConverter, and in that case, ourDefaultHandlerExceptionResolverwill just send a status code 400 back but not perform any further logging. We will have to do something about that... probably not inInvocableHandlerMethoditself but rather inDefaultHandlerExceptionResolver.Juergen
spring-projects-issues commentedon Jul 27, 2015
Juergen Hoeller commented
My current solution is to log at warn level for all conversion exceptions in
DefaultHandlerExceptionResolver, as a one-line entry with the exception type and message but no stacktrace. The full stacktrace would only be logged at debug level still, in order to avoid automatic escalations based on the presence of the stacktrace at warn level.The logging of HTTP request processing failures is a rather complex affair. Bad requests - either incomplete or badly structured - may come frequently and commonly, so don't necessarily suggest an error or even warn-level situation for a public web API. At the same time, common server execution problems shouldn't remain unnoticed either.
Note that you can always implement your own
HandlerExceptionResolverbean for yourDispatcherServletconfiguration (or an@ExceptionHandlermethod in your MVC controller) to provide your own exception handling, including warn or error level logging of your own. This is also the reason why we refrain from logging at warn or error level within Spring's processing infrastructure: In a custom exception handling scenario, such lower-level warn entries will be undesirable and cannot easily be suppressed. The configurableHandlerExceptionResolvermechanism provides a common point for enforcing such application-level exception handling policies at the very end of processing a specific request.Juergen
spring-projects-issues commentedon Jul 28, 2015
Juergen Hoeller commented
The changes above -
DefaultHandlerExceptionResolvertriggering warn log entries for conversion exceptions - will be available in the next4.2.0.BUILD-SNAPSHOT. Feel free to give it an early try...As mentioned, in particular with older versions of Spring, I'd recommend creating a custom
HandlerExceptionResolverimplementation (orDefaultHandlerExceptionResolversubclass) that logs at error or warn level as you see fit.Juergen
spring-projects-issues commentedon Jul 28, 2015
Steve Roy commented
Thank you Juergen.
We need to stay on Spring 4.1.X for now. I was able to override the DefaultHandlerExceptionResolver and achieve the desired effect until we upgrade. Glad it's tweaked in 4.2.