Skip to content

Commit

Permalink
feat: prod 환경의 로그를 일자별로 파일 저장한다. (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlarltj authored Jun 28, 2024
1 parent a62bf42 commit a5b6934
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/main/resources/appender/moneymong-file-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<included>
<appender name="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-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>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>


</included>
7 changes: 4 additions & 3 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
<property name="CONSOLE_LOG_PATTERN"
value="%clr(%d{yyyyMMdd HH:mm:ss.SSS}){magenta} %clr([%thread]){blue} %clr(%-5level){} %clr([%logger{0}:%line]){cyan} : %msg %n"/>

<property name="AWS_LOG_PATTERN"
value="[%thread] [%date] [%level] [%file:%line] - %msg%n"/>

<springProfile name="local">
<include resource="appender/moneymong-console-appender.xml"/>
<root level="INFO">
Expand All @@ -22,8 +19,12 @@

<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">
<appender-ref ref="FILE_APPENDER"/>
</root>
</springProfile>
</configuration>

0 comments on commit a5b6934

Please sign in to comment.