Skip to content

InvocableHandlerMethod.getMethodArgumentValues() failure should lead to warn-level logging by default [SPR-13267] #17858

Closed

Description

@spring-projects-issues

Steve Roy opened SPR-13267 and commented

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.

  • steve

Affects: 4.1.6

Issue Links:

Referenced from: commits 9e62c8e, 76d7f45

Activity

  1. spring-projects-issues commented on Jul 27, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    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...

    Juergen

  2. spring-projects-issues commented on Jul 27, 2015

    @spring-projects-issues
    CollaboratorAuthor

    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?

  3. spring-projects-issues commented on Jul 27, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    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?

    Juergen

  4. spring-projects-issues commented on Jul 27, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    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.

    Juergen

  5. spring-projects-issues commented on Jul 27, 2015

    @spring-projects-issues
    CollaboratorAuthor

    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 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.

    Juergen

  6. spring-projects-issues commented on Jul 28, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    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.

    Juergen

  7. spring-projects-issues commented on Jul 28, 2015

    @spring-projects-issues
    CollaboratorAuthor

    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.

    • steve
  8. added this to the 4.2 GA milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions