Skip to content

Commit

Permalink
feat: error log를 다른 파일로 분리한다.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlarltj committed Jul 1, 2024
1 parent a5b6934 commit 99667e1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/main/resources/appender/moneymong-error-file-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<included>
<appender name="ERROR_FILE_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>

<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/spring-boot-error-logging.%d{yyyy-MM-dd}_%i.log</fileNamePattern>

<!-- each file should be at most 10MB, keep 30 days worth of history -->
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50KB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>

</included>
11 changes: 7 additions & 4 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
<springProfile name="prod">
<include resource="appender/moneymong-console-appender.xml"/>
<include resource="appender/moneymong-file-appender.xml"/>
<root level="INFO">
<appender-ref ref="CONSOLE_APPENDER"/>
</root>
<root level="INFO">
<include resource="appender/moneymong-error-file-appender.xml"/>

<logger name="org.springframework" level="INFO" additivity="false">
<appender-ref ref="FILE_APPENDER"/>
</logger>

<root level="WARN">
<appender-ref ref="ERROR_FILE_APPENDER"/>
</root>
</springProfile>
</configuration>

0 comments on commit 99667e1

Please sign in to comment.