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] LogBack 롤링 정책 수정, 로그 레벨에 따른 분리 #332

Merged
merged 2 commits into from
Aug 13, 2024
Merged
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
12 changes: 0 additions & 12 deletions server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ management:
exposure:
include: health, metrics, logfile

logging:
level:
root: debug
org.springframework.web: debug
server.haengdong: debug

file:
name: logs/spring-boot-application.log
path: logs
config: classpath:logback-spring.xml

server:
servlet:
encoding:
Expand All @@ -75,4 +64,3 @@ spring:
import: classpath:config/application-dev.yml
activate:
on-profile: dev

2 changes: 1 addition & 1 deletion server/src/main/resources/config
88 changes: 80 additions & 8 deletions server/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,71 @@
<configuration>
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/spring-boot-application.log</file>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- 콘솔에 로그 출력 형식 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<appender name="ERROR-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>logs/spring-boot-application-error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/spring-boot-application-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<!-- 날짜, 시간, 로그 레벨, 스레드 이름, 로거 이름, 메시지 형식 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<appender name="WARN-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>logs/spring-boot-application-warn.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/spring-boot-application-warn.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<!-- 날짜, 시간, 로그 레벨, 스레드 이름, 로거 이름, 메시지 형식 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<appender name="INFO-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>logs/spring-boot-application-info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/spring-boot-application-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<!-- 날짜, 시간, 로그 레벨, 스레드 이름, 로거 이름, 메시지 형식 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<appender name="DEBUG-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>logs/spring-boot-application-debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/spring-boot-application.%d{yyyy-MM-dd}.log</fileNamePattern>
<fileNamePattern>logs/spring-boot-application-debug.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
Expand All @@ -11,10 +74,19 @@
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="ROLLING"/>
</root>
<springProfile name="default">
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>

<logger name="org.springframework.web" level="DEBUG"/>
<logger name="server.haengdong" level="DEBUG"/>
<springProfile name="default">
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ERROR-ROLLING"/>
<appender-ref ref="WARN-ROLLING"/>
<appender-ref ref="INFO-ROLLING"/>
<appender-ref ref="DEBUG-ROLLING"/>
</root>
</springProfile>
</configuration>
Loading