Skip to content

AbstractHandlerExceptionResolver logs handled exceptions at WARN [SPR-17399] #21932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Oct 17, 2018 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Oct 17, 2018

Dale Ogilvie opened SPR-17399 and commented

We have a ControllerAdvice exceptionHandler which logs 404 at INFO, as this is not an error we care about. However, ExceptionHandlerExceptionResolver logs at WARN after calling our handler. This should not happen.

Example log:

2018-10-18 10:24:43,594 BELLHOP INFO  main   * HttpClient Error: 404 Not Found, ErrorMessage [url=/api/platforms/NOTFOUND/radio, reason={"message":"No configuration found for NOTFOUND"}] * api.RestExceptionHandlerController            * main * nz.co.trimble.bellhop.api.RestExceptionHandlerController
2018-10-18 10:24:43,631 BELLHOP WARN  main   * Resolved [org.springframework.web.client.HttpClientErrorException: 404 Not Found]          * annotation.ExceptionHandlerExceptionResolver  * main * org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver 
@Override
public ModelAndView resolveException(
    HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {

  if (shouldApplyTo(request, handler)) {
    prepareResponse(ex, response);
    ModelAndView result = doResolveException(request, response, handler, ex);
    if (result != null) {
      // Print warn message when warn logger is not enabled...
      if (logger.isWarnEnabled() && (this.warnLogger == null || !this.warnLogger.isWarnEnabled())) {
        logger.warn("Resolved [" + ex + "]" + (result.isEmpty() ? "" : " to " + result));
      }
      // warnLogger with full stack trace (requires explicit config)
      logException(ex, request);
    }
    return result;
  }
  else {
    return null;
  }
}

Affects: 4.3.19

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Oct 18, 2018

Rossen Stoyanchev commented

This is a duplicate of #21916.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants