diff --git a/backend/src/main/java/com/festago/common/aop/LogRequestBodyAspect.java b/backend/src/main/java/com/festago/common/aop/LogRequestBodyAspect.java index 205d4d6b0..8efb02a71 100644 --- a/backend/src/main/java/com/festago/common/aop/LogRequestBodyAspect.java +++ b/backend/src/main/java/com/festago/common/aop/LogRequestBodyAspect.java @@ -13,7 +13,6 @@ import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.reflect.MethodSignature; -import org.slf4j.Logger; import org.slf4j.event.Level; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; @@ -31,14 +30,12 @@ public class LogRequestBodyAspect { private final Map> loggerMap = new EnumMap<>(Level.class); private final ObjectMapper objectMapper; - private final Logger errorLogger; - public LogRequestBodyAspect(ObjectMapper objectMapper, Logger errorLogger) { + public LogRequestBodyAspect(ObjectMapper objectMapper) { this.objectMapper = objectMapper; - this.errorLogger = errorLogger; - loggerMap.put(Level.INFO, this.errorLogger::info); - loggerMap.put(Level.WARN, this.errorLogger::warn); - loggerMap.put(Level.ERROR, this.errorLogger::error); + loggerMap.put(Level.INFO, log::info); + loggerMap.put(Level.WARN, log::warn); + loggerMap.put(Level.ERROR, log::error); } @Around("@annotation(LogRequestBody)") @@ -49,7 +46,7 @@ public Object handleAll(ProceedingJoinPoint pjp) throws Throwable { Level level = annotation.level(); ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - if (attributes == null || !errorLogger.isEnabledForLevel(level)) { + if (attributes == null || !log.isEnabledForLevel(level)) { return pjp.proceed(); } HttpServletRequest request = attributes.getRequest(); diff --git a/backend/src/main/java/com/festago/common/handler/GlobalExceptionHandler.java b/backend/src/main/java/com/festago/common/handler/GlobalExceptionHandler.java index 5ef69d696..0d314d4d3 100644 --- a/backend/src/main/java/com/festago/common/handler/GlobalExceptionHandler.java +++ b/backend/src/main/java/com/festago/common/handler/GlobalExceptionHandler.java @@ -16,6 +16,7 @@ import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatusCode; @@ -31,6 +32,7 @@ @RequiredArgsConstructor public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { + private static final Logger log = LoggerFactory.getLogger("ErrorLogger"); private static final String LOG_FORMAT_INFO = "\n[🔵INFO] - ({} {})\n(id: {}, role: {})\n{}\n {}: {}"; private static final String LOG_FORMAT_WARN = "\n[🟠WARN] - ({} {})\n(id: {}, role: {})"; private static final String LOG_FORMAT_ERROR = "\n[🔴ERROR] - ({} {})\n(id: {}, role: {})"; @@ -60,7 +62,6 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { */ private final AuthenticateContext authenticateContext; - private final Logger errorLogger; @ExceptionHandler(InvalidMediaTypeException.class) public ResponseEntity handle(InvalidMediaTypeException e) { @@ -133,23 +134,17 @@ protected ResponseEntity handleMethodArgumentNotValid( } private void logInfo(FestaGoException e, HttpServletRequest request) { - if (errorLogger.isInfoEnabled()) { - errorLogger.info(LOG_FORMAT_INFO, request.getMethod(), request.getRequestURI(), authenticateContext.getId(), - authenticateContext.getRole(), e.getErrorCode(), e.getClass().getName(), e.getMessage()); - } + log.info(LOG_FORMAT_INFO, request.getMethod(), request.getRequestURI(), authenticateContext.getId(), + authenticateContext.getRole(), e.getErrorCode(), e.getClass().getName(), e.getMessage()); } private void logWarn(FestaGoException e, HttpServletRequest request) { - if (errorLogger.isWarnEnabled()) { - errorLogger.warn(LOG_FORMAT_WARN, request.getMethod(), request.getRequestURI(), - authenticateContext.getId(), authenticateContext.getRole(), e); - } + log.warn(LOG_FORMAT_WARN, request.getMethod(), request.getRequestURI(), + authenticateContext.getId(), authenticateContext.getRole(), e); } private void logError(Exception e, HttpServletRequest request) { - if (errorLogger.isErrorEnabled()) { - errorLogger.error(LOG_FORMAT_ERROR, request.getMethod(), request.getRequestURI(), - authenticateContext.getId(), authenticateContext.getRole(), e); - } + log.error(LOG_FORMAT_ERROR, request.getMethod(), request.getRequestURI(), + authenticateContext.getId(), authenticateContext.getRole(), e); } } diff --git a/backend/src/main/java/com/festago/config/ErrorLoggerConfig.java b/backend/src/main/java/com/festago/config/ErrorLoggerConfig.java deleted file mode 100644 index d0ec785df..000000000 --- a/backend/src/main/java/com/festago/config/ErrorLoggerConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.festago.config; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ErrorLoggerConfig { - - @Bean - public Logger errorLogger() { - return LoggerFactory.getLogger("ErrorLogger"); - } -} diff --git a/backend/src/main/resources/config b/backend/src/main/resources/config index 73c3c51a0..808a39ab1 160000 --- a/backend/src/main/resources/config +++ b/backend/src/main/resources/config @@ -1 +1 @@ -Subproject commit 73c3c51a0b3b1cdb63c750ee18e9ad33973d4d86 +Subproject commit 808a39ab1f8c51672dd1a3b8cc5d1f1643679023 diff --git a/backend/src/main/resources/logback-spring.xml b/backend/src/main/resources/logback-spring.xml index 1e0713bc2..8454df8e3 100644 --- a/backend/src/main/resources/logback-spring.xml +++ b/backend/src/main/resources/logback-spring.xml @@ -20,20 +20,17 @@ - - - @@ -44,22 +41,17 @@ - - - - - diff --git a/backend/src/main/resources/logs/slack/slack-error-appender.xml b/backend/src/main/resources/logs/slack/slack-error-appender.xml deleted file mode 100644 index 3a423d95c..000000000 --- a/backend/src/main/resources/logs/slack/slack-error-appender.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - ${WEBHOOK_URL} - - ${FILE_LOG_PATTERN} - - true - - - - - - ERROR - ACCEPT - DENY - - - diff --git a/backend/src/main/resources/logs/slack/slack-warn-appender.xml b/backend/src/main/resources/logs/slack/slack-warn-appender.xml deleted file mode 100644 index f2ad7079b..000000000 --- a/backend/src/main/resources/logs/slack/slack-warn-appender.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - ${WEBHOOK_URL} - - ${FILE_LOG_PATTERN} - - true - - - - - - WARN - ACCEPT - DENY - - - diff --git a/backend/src/test/java/com/festago/support/CustomWebMvcTest.java b/backend/src/test/java/com/festago/support/CustomWebMvcTest.java index 03b00c308..42063b6cb 100644 --- a/backend/src/test/java/com/festago/support/CustomWebMvcTest.java +++ b/backend/src/test/java/com/festago/support/CustomWebMvcTest.java @@ -1,7 +1,6 @@ package com.festago.support; import com.festago.common.aop.ValidPageableAspect; -import com.festago.config.ErrorLoggerConfig; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -12,8 +11,7 @@ @EnableAspectJAutoProxy @WebMvcTest -@Import({TestAuthConfig.class, ErrorLoggerConfig.class, MockAllServiceBeanFactoryPostProcessor.class, - ValidPageableAspect.class}) +@Import({TestAuthConfig.class, MockAllServiceBeanFactoryPostProcessor.class, ValidPageableAspect.class}) @Retention(RetentionPolicy.RUNTIME) @TestExecutionListeners(value = {MockAuthTestExecutionListener.class, ResetMockTestExecutionListener.class}, mergeMode = MergeMode.MERGE_WITH_DEFAULTS)