From 006874b9a9729e0b05a8e3aeb6d9eaf89b4a8205 Mon Sep 17 00:00:00 2001 From: KJBig Date: Tue, 1 Oct 2024 14:43:32 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EB=A1=9C=EA=B7=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/GlobalExceptionHandler.java | 19 ++++++++++++------- .../api/common/log/RestControllerLogAop.java | 4 ++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/sluv-api/src/main/java/com/sluv/api/common/exception/GlobalExceptionHandler.java b/sluv-api/src/main/java/com/sluv/api/common/exception/GlobalExceptionHandler.java index 9626dd7d..ab279264 100644 --- a/sluv-api/src/main/java/com/sluv/api/common/exception/GlobalExceptionHandler.java +++ b/sluv-api/src/main/java/com/sluv/api/common/exception/GlobalExceptionHandler.java @@ -16,8 +16,8 @@ @Slf4j public class GlobalExceptionHandler { - private static final String LOG_FORMAT = "Error: {}, Class : {}, Message : {}"; - private static final String LOG_CODE_FORMAT = "Error: {}, Class : {}, Code : {}, Message : {}"; + private static final String LOG_FORMAT = "Error: {}, Class : {}, Message : {}, Stack : {}"; + private static final String LOG_CODE_FORMAT = "Error: {}, Class : {}, Code : {}, Message : {}, Stack : {}"; /** * == Application Exception == @@ -32,7 +32,8 @@ public ResponseEntity applicationException(ApplicationException e "ApplicationException", exception.getClass().getSimpleName(), exception.getErrorCode(), - exception.getMessage() + exception.getMessage(), + exception.getStackTrace() ); HttpStatus httpStatus = HttpStatus.valueOf(exception.getHttpStatusCode().getCode()); @@ -51,7 +52,8 @@ public ResponseEntity handleMethodArgumentTypeMismatch(HttpMessag LOG_FORMAT, "HttpMessageNotReadableException", exception.getClass().getSimpleName(), - exception.getMessage() + exception.getMessage(), + exception.getStackTrace() ); return ResponseEntity.badRequest() @@ -75,7 +77,8 @@ public ResponseEntity runtimeException(RuntimeException exception LOG_FORMAT, "RuntimeException", exception.getClass().getSimpleName(), - exception.getMessage() + exception.getMessage(), + exception.getStackTrace() ); return ResponseEntity.internalServerError() @@ -98,7 +101,8 @@ public ResponseEntity dataAccessException(DataAccessException exc LOG_FORMAT, "DataAccessException", exception.getClass().getSimpleName(), - exception.getMessage() + exception.getMessage(), + exception.getStackTrace() ); return ResponseEntity.badRequest() @@ -121,7 +125,8 @@ public ResponseEntity handleException(Exception exception) { LOG_FORMAT, "Exception", exception.getClass().getSimpleName(), - exception.getMessage() + exception.getMessage(), + exception.getStackTrace() ); return ResponseEntity.internalServerError() .body(ErrorResponse.customBuilder() diff --git a/sluv-api/src/main/java/com/sluv/api/common/log/RestControllerLogAop.java b/sluv-api/src/main/java/com/sluv/api/common/log/RestControllerLogAop.java index 146bbfa9..29be26ad 100644 --- a/sluv-api/src/main/java/com/sluv/api/common/log/RestControllerLogAop.java +++ b/sluv-api/src/main/java/com/sluv/api/common/log/RestControllerLogAop.java @@ -30,7 +30,7 @@ public void beforeParameterLog(JoinPoint joinPoint) { if (requestAttributes != null) { HttpServletRequest request = requestAttributes.getRequest(); // Log the requested URL - log.info("====== Requested URL: {} ======", request.getRequestURI()); + log.info("====== Requested URL: {} - {} ======", request.getMethod(), request.getRequestURI()); } if (requestAttributes == null) { @@ -65,7 +65,7 @@ public void afterReturnLog(JoinPoint joinPoint, Object returnObj) { if (requestAttributes != null) { HttpServletRequest request = requestAttributes.getRequest(); // Log the requested URL - log.info("Requested URL: {}", request.getRequestURI()); + log.info("Requested URL: {} - {}", request.getMethod(), request.getRequestURI()); } if (requestAttributes == null) { log.info("====== Requested URL: Unknown ======");