Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] fix: logback으로 남기는 로그 통합 (#888) #889

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import com.festago.common.exception.dto.ValidErrorResponse;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
Expand All @@ -28,11 +27,11 @@
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

@Slf4j
@RestControllerAdvice
@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: {})";
Expand Down
38 changes: 4 additions & 34 deletions backend/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,10 @@
</root>
</springProfile>

<springProfile name="dev">
<include resource="logs/common/file-info-appender.xml"/>
<include resource="logs/common/file-warn-appender.xml"/>
<include resource="logs/common/file-error-appender.xml"/>
<include resource="logs/error/file-info-appender.xml"/>
<include resource="logs/error/file-warn-appender.xml"/>
<include resource="logs/error/file-error-appender.xml"/>

<logger additivity="false" level="INFO" name="ErrorLogger">
<appender-ref ref="ERROR_ERROR"/>
<appender-ref ref="ERROR_WARN"/>
<appender-ref ref="ERROR_INFO"/>
</logger>

<root level="INFO">
<appender-ref ref="FILE-INFO"/>
<appender-ref ref="FILE-WARN"/>
<appender-ref ref="FILE-ERROR"/>
</root>
</springProfile>

<springProfile name="prod">
<include resource="logs/common/file-info-appender.xml"/>
<include resource="logs/common/file-warn-appender.xml"/>
<include resource="logs/common/file-error-appender.xml"/>
<include resource="logs/error/file-info-appender.xml"/>
<include resource="logs/error/file-warn-appender.xml"/>
<include resource="logs/error/file-error-appender.xml"/>

<logger additivity="false" level="INFO" name="ErrorLogger">
<appender-ref ref="ERROR_ERROR"/>
<appender-ref ref="ERROR_WARN"/>
<appender-ref ref="ERROR_INFO"/>
</logger>
<springProfile name="dev,prod">
<include resource="logs/file-info-appender.xml"/>
<include resource="logs/file-warn-appender.xml"/>
<include resource="logs/file-error-appender.xml"/>

<root level="INFO">
<appender-ref ref="FILE-INFO"/>
Expand Down
19 changes: 0 additions & 19 deletions backend/src/main/resources/logs/error/file-error-appender.xml

This file was deleted.

19 changes: 0 additions & 19 deletions backend/src/main/resources/logs/error/file-info-appender.xml

This file was deleted.

19 changes: 0 additions & 19 deletions backend/src/main/resources/logs/error/file-warn-appender.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/log/common/error/error-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<fileNamePattern>${LOG_PATH}/log/error/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>100MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/log/common/info/info-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<fileNamePattern>${LOG_PATH}/log/info/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>100MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/log/common/warn/warn-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<fileNamePattern>${LOG_PATH}/log/warn/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>100MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
Expand Down
Loading