Skip to content

Commit

Permalink
#323 [chore] 알림 서버 logback 설정 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
orijoon98 committed Apr 28, 2023
1 parent ab7f4d0 commit 81d3004
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hous-notification/src/main/resources/console-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<included>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
</included>
21 changes: 21 additions & 0 deletions hous-notification/src/main/resources/file-error-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<included>
<appender name="FILE-ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/home/ubuntu/hous-notification/logs/error/error.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder>
<pattern>${LOG_PATTERN}</pattern>
</encoder>
<!-- 일자별 로그파일 생성 -->
<!-- Application이 동작중일 땐 활성화된 로그 파일에 로그를 쌓이고, 매일 자정이 지나면 info-2020-10-03.log 와 같은 이름으로 생성 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/home/ubuntu/hous-notification/logs/error/error-%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 30일동안, 최대 3GB의 log를 저장함 -->
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
</appender>
</included>
21 changes: 21 additions & 0 deletions hous-notification/src/main/resources/file-info-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<included>
<appender name="FILE-INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/home/ubuntu/hous-notification/logs/info/info.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder>
<pattern>${LOG_PATTERN}</pattern>
</encoder>
<!-- 일자별 로그파일 생성 -->
<!-- Application이 동작중일 땐 활성화된 로그 파일에 로그를 쌓이고, 매일 자정이 지나면 info-2020-10-03.log 와 같은 이름으로 생성 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/home/ubuntu/hous-notification/logs/info/info-%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 30일동안, 최대 3GB의 log를 저장함 -->
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
</appender>
</included>
21 changes: 21 additions & 0 deletions hous-notification/src/main/resources/file-warn-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<included>
<appender name="FILE-WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/home/ubuntu/hous-notification/logs/warn/warn.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder>
<pattern>${LOG_PATTERN}</pattern>
</encoder>
<!-- 일자별 로그파일 생성 -->
<!-- Application이 동작중일 땐 활성화된 로그 파일에 로그를 쌓이고, 매일 자정이 지나면 info-2020-10-03.log 와 같은 이름으로 생성 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/home/ubuntu/hous-notification/logs/warn/warn-%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 30일동안, 최대 3GB의 log를 저장함 -->
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
</appender>
</included>
27 changes: 27 additions & 0 deletions hous-notification/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOG_PATTERN"
value="[%d{yyyy-MM-dd HH:mm:ss}:%-4relative] %green([%thread]) %highlight(%-5level) %boldWhite([%C.%M:%yellow(%L)]) - %msg%n"/>

<!-- prod 환경이 아닌 경우, ConsoleAppender 사용하여 콘솔창에 보임 -->
<springProfile name="local">
<include resource="console-appender.xml"/>

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

<!-- [Log Level] TRACE < DEBUG < INFO < WARN < ERROR 대소문자 구분 안함 -->
<springProfile name="!local">
<include resource="file-info-appender.xml"/>
<include resource="file-warn-appender.xml"/>
<include resource="file-error-appender.xml"/>

<root level="INFO">
<appender-ref ref="FILE-INFO"/>
<appender-ref ref="FILE-WARN"/>
<appender-ref ref="FILE-ERROR"/>
</root>
</springProfile>
</configuration>

0 comments on commit 81d3004

Please sign in to comment.