Skip to content

Commit

Permalink
Feat: 로그 파일 저장 설정용 logback-spring.yml 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
WonSteps committed Oct 23, 2024
1 parent 5387fd6 commit 8cd6835
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ out/
### etc ###
.DS_Store

### Project ###
**/main/generated/

**/resources/.env
**/resources/.env.*
!**/resources/.env.example

**/resources/app/apple/*.p8

### Logs ###
logs/**
45 changes: 45 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<configuration>
<property resource="logback-variables.properties"/>

<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>

<timestamp key="ToMonth" datePattern="yyyy-MM"/>
<timestamp key="ToDay" datePattern="yyyy-MM-dd"/>

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%clr(%d{${LOG_DATEFORMAT_PATTERN}}){magenta} %clr([%thread]){blue} %clr(%-5level){} %clr([%logger{0}:%line]){cyan} : %msg %n
</pattern>
</layout>
</appender>

<appender name="FILE1" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
<timestampFormat>${LOG_DATEFORMAT_PATTERN}</timestampFormat>

<timestampFormatTimezoneId>Asia/Seoul</timestampFormatTimezoneId>
<appendLineSeparator>true</appendLineSeparator>

<jsonFormatter class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
<prettyPrint>false</prettyPrint>
</jsonFormatter>
</layout>
</encoder>

<file>${LOG_PATH}/${ToMonth}/${ToDay}_${LOG_FILE_NAME}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>
${LOG_PATH}/%d{yyyy-MM}/%d{yyyy-MM-dd}_${LOG_FILE_NAME}_%i.log
</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
</appender>

<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE1"/>
</root>

</configuration>
3 changes: 3 additions & 0 deletions src/main/resources/logback-variables.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LOG_PATH = ./logs
LOG_FILE_NAME = runus
LOG_DATEFORMAT_PATTERN = yyyy-MM-dd HH:mm:ss.SSSX

0 comments on commit 8cd6835

Please sign in to comment.