Skip to content

Commit

Permalink
Revert "@ExceptionHandler methods logs at DEBUG level again"
Browse files Browse the repository at this point in the history
This reverts commit 162112.

Instead we'll go for a bigger rollback of the change from SPR-17178 so
that only DefaultHandlerExceptionResolver does warn logging by default.

Issue: SPR-17388
  • Loading branch information
rstoyanchev committed Oct 22, 2018
1 parent 0176d36 commit de453ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
Expand Up @@ -135,18 +135,11 @@ public ModelAndView resolveException(
prepareResponse(ex, response);
ModelAndView result = doResolveException(request, response, handler, ex);
if (result != null) {
// Print warn or debug message when warn logger is not enabled...
if (this.warnLogger == null || !this.warnLogger.isWarnEnabled()) {
if (!useWarnLevelWhenWarnLoggerNotEnabled()) {
if (logger.isDebugEnabled()) {
logger.debug("Resolved [" + ex + "]" + (result.isEmpty() ? "" : " to " + result));
}
}
else if (logger.isWarnEnabled()) {
logger.warn("Resolved [" + ex + "]" + (result.isEmpty() ? "" : " to " + result));
}
// 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));
}
// Log with warnLogger (requires explicit config)
// warnLogger with full stack trace (requires explicit config)
logException(ex, request);
}
return result;
Expand Down Expand Up @@ -186,16 +179,6 @@ protected boolean shouldApplyTo(HttpServletRequest request, @Nullable Object han
return (this.mappedHandlers == null && this.mappedHandlerClasses == null);
}

/**
* Whether to log warn level messages (return value "true") or debug level
* messages (return value "false") through the regular class logger when
* {@link #setWarnLogCategory warn logging} is not activated.
* <p>By default returns "true".
*/
protected boolean useWarnLevelWhenWarnLoggerNotEnabled() {
return true;
}

/**
* Log the given exception at warn level, provided that warn logging has been
* activated through the {@link #setWarnLogCategory "warnLogCategory"} property.
Expand Down
Expand Up @@ -491,10 +491,4 @@ protected ServletInvocableHandlerMethod getExceptionHandlerMethod(
return null;
}

@Override
protected boolean useWarnLevelWhenWarnLoggerNotEnabled() {
// Use DEBUG level
return false;
}

}

0 comments on commit de453ac

Please sign in to comment.