Skip to content

Commit

Permalink
Merge pull request #209 from softeerbootcamp4th/feature/#203-rush-eve…
Browse files Browse the repository at this point in the history
…nt-apply-stress-test

fix: logback-spring.xml 에 info, warn, error 로그 각각 파일로 기록하도록 수정
  • Loading branch information
k000927 authored Aug 21, 2024
2 parents 112f211 + 7a7bf29 commit 290f64d
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions Server/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<!-- 로컬 환경 -->
<springProfile name="local">
<!-- INFO 로그 파일 저장 설정 -->
<appender name="INFO_FILE_LOCAL" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./logs/info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
Expand All @@ -19,17 +20,63 @@
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg [%X{requestId}]%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>

<!-- WARN 로그 파일 저장 설정 -->
<appender name="WARN_FILE_LOCAL" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./logs/warn.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>./logs/warn.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg [%X{requestId}]%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>

<!-- ERROR 로그 파일 저장 설정 -->
<appender name="ERROR_FILE_LOCAL" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./logs/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>./logs/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg [%X{requestId}]%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>

<!-- 루트 로거 설정 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="INFO_FILE_LOCAL" />
<appender-ref ref="WARN_FILE_LOCAL" />
<appender-ref ref="ERROR_FILE_LOCAL" />
</root>
</springProfile>

<!-- 프로덕션 환경 -->
<springProfile name="prod">
<!-- INFO 로그 파일 저장 설정 -->
<appender name="INFO_FILE_PROD" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/logs/info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
Expand All @@ -41,12 +88,57 @@
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg [%X{requestId}]%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>

<!-- WARN 로그 파일 저장 설정 -->
<appender name="WARN_FILE_PROD" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/logs/warn.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>/logs/warn.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg [%X{requestId}]%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>

<!-- ERROR 로그 파일 저장 설정 -->
<appender name="ERROR_FILE_PROD" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/logs/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>/logs/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg [%X{requestId}]%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>

<!-- 루트 로거 설정 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="INFO_FILE_PROD" />
<appender-ref ref="WARN_FILE_PROD" />
<appender-ref ref="ERROR_FILE_PROD" />
</root>
</springProfile>
</configuration>

0 comments on commit 290f64d

Please sign in to comment.