@@ -283,11 +283,9 @@ private void sendErrorResponseFromException(final HttpServletRequest request,
283283 if (statusCodesLoggedAsErrors .contains (statusCode )) {
284284 log .error ("{} (status:{})" , message , statusCode , ex );
285285 } else {
286- // Log the error as a single-line WARN
287286 StackTraceElement [] trace = ex .getStackTrace ();
288287 String location = trace .length <= 0 ? "unknown" : trace [0 ].toString ();
289- log .warn ("{} (status:{} exception: {} at: {})" ,
290- message , statusCode , ex .getClass ().getName (), location );
288+ logClientError (statusCode , message , ex .getClass ().getName (), location );
291289 }
292290
293291 response .sendError (statusCode , message );
@@ -322,7 +320,6 @@ private void sendErrorResponse(final HttpServletRequest request,
322320 // Log the full error and status code
323321 log .error ("{} (status:{})" , message , statusCode , ex );
324322 } else if (HttpStatus .valueOf (statusCode ).is4xxClientError ()) {
325- // Log the error as a single-line WARN
326323 String location ;
327324 String exceptionMessage ;
328325 if (null == ex ) {
@@ -333,14 +330,27 @@ private void sendErrorResponse(final HttpServletRequest request,
333330 StackTraceElement [] trace = ex .getStackTrace ();
334331 location = trace .length <= 0 ? "unknown" : trace [0 ].toString ();
335332 }
336- log .warn ("{} (status:{} exception: {} at: {})" , message , statusCode ,
337- exceptionMessage , location );
333+ logClientError (statusCode , message , exceptionMessage , location );
338334 }
339335
340336 //Exception properties will be set by org.springframework.boot.web.support.ErrorPageFilter
341337 response .sendError (statusCode , message );
342338 }
343339
340+ /**
341+ * Log a 4xx client error. 404 NOT_FOUND is logged at DEBUG level (normal REST response),
342+ * all other 4xx errors are logged at WARN level.
343+ */
344+ private void logClientError (int statusCode , String message , String exceptionMessage , String location ) {
345+ if (statusCode == HttpServletResponse .SC_NOT_FOUND ) {
346+ log .debug ("{} (status:{} exception: {} at: {})" , message , statusCode ,
347+ exceptionMessage , location );
348+ } else {
349+ log .warn ("{} (status:{} exception: {} at: {})" , message , statusCode ,
350+ exceptionMessage , location );
351+ }
352+ }
353+
344354 /**
345355 * Get set of status codes that should be treated as errors.
346356 *
0 commit comments