Skip to content

Commit de453ac

Browse files
committed
Revert "@ExceptionHandler methods logs at DEBUG level again"
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
1 parent 0176d36 commit de453ac

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerExceptionResolver.java

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,11 @@ public ModelAndView resolveException(
135135
prepareResponse(ex, response);
136136
ModelAndView result = doResolveException(request, response, handler, ex);
137137
if (result != null) {
138-
// Print warn or debug message when warn logger is not enabled...
139-
if (this.warnLogger == null || !this.warnLogger.isWarnEnabled()) {
140-
if (!useWarnLevelWhenWarnLoggerNotEnabled()) {
141-
if (logger.isDebugEnabled()) {
142-
logger.debug("Resolved [" + ex + "]" + (result.isEmpty() ? "" : " to " + result));
143-
}
144-
}
145-
else if (logger.isWarnEnabled()) {
146-
logger.warn("Resolved [" + ex + "]" + (result.isEmpty() ? "" : " to " + result));
147-
}
138+
// Print warn message when warn logger is not enabled...
139+
if (logger.isWarnEnabled() && (this.warnLogger == null || !this.warnLogger.isWarnEnabled())) {
140+
logger.warn("Resolved [" + ex + "]" + (result.isEmpty() ? "" : " to " + result));
148141
}
149-
// Log with warnLogger (requires explicit config)
142+
// warnLogger with full stack trace (requires explicit config)
150143
logException(ex, request);
151144
}
152145
return result;
@@ -186,16 +179,6 @@ protected boolean shouldApplyTo(HttpServletRequest request, @Nullable Object han
186179
return (this.mappedHandlers == null && this.mappedHandlerClasses == null);
187180
}
188181

189-
/**
190-
* Whether to log warn level messages (return value "true") or debug level
191-
* messages (return value "false") through the regular class logger when
192-
* {@link #setWarnLogCategory warn logging} is not activated.
193-
* <p>By default returns "true".
194-
*/
195-
protected boolean useWarnLevelWhenWarnLoggerNotEnabled() {
196-
return true;
197-
}
198-
199182
/**
200183
* Log the given exception at warn level, provided that warn logging has been
201184
* activated through the {@link #setWarnLogCategory "warnLogCategory"} property.

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,4 @@ protected ServletInvocableHandlerMethod getExceptionHandlerMethod(
491491
return null;
492492
}
493493

494-
@Override
495-
protected boolean useWarnLevelWhenWarnLoggerNotEnabled() {
496-
// Use DEBUG level
497-
return false;
498-
}
499-
500494
}

0 commit comments

Comments
 (0)