Skip to content

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

@spring-projects-issues

Description

@spring-projects-issues

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:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issuetype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions