Skip to content

Commit

Permalink
feat: 로그 추가 (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
This2sho authored Jul 1, 2024
1 parent 4a93c13 commit 0e67505
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions domain/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ dependencies {
// flyway 추가
implementation 'org.flywaydb:flyway-mysql'
implementation 'org.flywaydb:flyway-core'

// log 추가
implementation 'ch.qos.logback.contrib:logback-jackson:0.1.5'
implementation 'ch.qos.logback.contrib:logback-json-classic:0.1.5'
implementation 'net.logstash.logback:logstash-logback-encoder:6.1'
}
38 changes: 38 additions & 0 deletions domain/src/main/resources/console-error-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<included>
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./logs/error.log</file>

<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>

<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<mdc/>
<pattern>
<pattern>
{
"timestamp": "%date{yyyyMMdd HHmmss.SSSSSS}",
"message": "%message",
"stacktrace": "%rEx"
}
</pattern>
</pattern>
</providers>
<timestampPattern>yyyyMMddHHmmss.SSSSSS</timestampPattern>
</encoder>

<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>./logs/history/error-history.log.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
<!-- 한 로그 파일이 50MB 차면 위 fileNamePattern으로 분리해 저장한다 -->
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>30</maxHistory>
<totalSizeCap>2GB</totalSizeCap>
<!-- 30일이 경과하거나, 전체 로그파일 용향이 2GB를 초과하면 오래된 파일 순으로 삭제한다. -->
</rollingPolicy>
</appender>
</included>

0 comments on commit 0e67505

Please sign in to comment.