Skip to content

Commit

Permalink
fix : 로그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
KJBig committed Oct 1, 2024
1 parent a3a9a0a commit 006874b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ==
Expand All @@ -32,7 +32,8 @@ public ResponseEntity<ErrorResponse> applicationException(ApplicationException e
"ApplicationException",
exception.getClass().getSimpleName(),
exception.getErrorCode(),
exception.getMessage()
exception.getMessage(),
exception.getStackTrace()
);
HttpStatus httpStatus = HttpStatus.valueOf(exception.getHttpStatusCode().getCode());

Expand All @@ -51,7 +52,8 @@ public ResponseEntity<ErrorResponse> handleMethodArgumentTypeMismatch(HttpMessag
LOG_FORMAT,
"HttpMessageNotReadableException",
exception.getClass().getSimpleName(),
exception.getMessage()
exception.getMessage(),
exception.getStackTrace()
);

return ResponseEntity.badRequest()
Expand All @@ -75,7 +77,8 @@ public ResponseEntity<ErrorResponse> runtimeException(RuntimeException exception
LOG_FORMAT,
"RuntimeException",
exception.getClass().getSimpleName(),
exception.getMessage()
exception.getMessage(),
exception.getStackTrace()
);

return ResponseEntity.internalServerError()
Expand All @@ -98,7 +101,8 @@ public ResponseEntity<ErrorResponse> dataAccessException(DataAccessException exc
LOG_FORMAT,
"DataAccessException",
exception.getClass().getSimpleName(),
exception.getMessage()
exception.getMessage(),
exception.getStackTrace()
);

return ResponseEntity.badRequest()
Expand All @@ -121,7 +125,8 @@ public ResponseEntity<ErrorResponse> handleException(Exception exception) {
LOG_FORMAT,
"Exception",
exception.getClass().getSimpleName(),
exception.getMessage()
exception.getMessage(),
exception.getStackTrace()
);
return ResponseEntity.internalServerError()
.body(ErrorResponse.customBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 ======");
Expand Down

0 comments on commit 006874b

Please sign in to comment.