Skip to content

Commit

Permalink
Merge pull request #276 from Juinjang/feat/#270
Browse files Browse the repository at this point in the history
[feat/#270] 로깅 파일 추가
  • Loading branch information
PicturePark1101 authored Jan 17, 2025
2 parents a7ed83f + 5863b0a commit 516b7f2
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 0 deletions.
129 changes: 129 additions & 0 deletions src/main/resources/logback-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<included>
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>

<property name="CONSOLE_LOG_PATTERN" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%clr(%-5level)] [%thread] [%logger{1}] - %msg%n"/>
<property name="INFO_LOG_PATTERN" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%5level] [%thread] [%logger{1}] - %msg%n"/>
<property name="WARN_LOG_PATTERN" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%5level] [%thread] [%logger{1}] - %msg%n"/>
<property name="ERROR_LOG_PATTERN" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%5level] [%thread] [%logger{1}] - %msg%n"/>

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
</layout>
</appender>

<appender name="API_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
</layout>
</appender>

<appender name="CONSOLE_INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/console/info-${SERVER_INFO}-console.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/console/info-${SERVER_INFO}-console-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<maxHistory>7</maxHistory>
<totalSizeCap>100MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${INFO_LOG_PATTERN}</pattern>
</encoder>
</appender>

<appender name="CONSOLE_WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/console/warn-${SERVER_INFO}-console.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/warn-console/${SERVER_INFO}-console-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<maxHistory>7</maxHistory>
<totalSizeCap>100MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${WARN_LOG_PATTERN}</pattern>
</encoder>
</appender>

<appender name="CONSOLE_ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/console/error-${SERVER_INFO}-console.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/console/error-${SERVER_INFO}-console-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<maxHistory>7</maxHistory>
<totalSizeCap>100MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${ERROR_LOG_PATTERN}</pattern>
</encoder>
</appender>

<appender name="API_INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/api/info-${SERVER_INFO}-api.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/api/info-${SERVER_INFO}-api-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<maxHistory>7</maxHistory>
<totalSizeCap>100MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${INFO_LOG_PATTERN}</pattern>
</encoder>
</appender>

<appender name="API_WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/api/warn-${SERVER_INFO}-api.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/api/warn-${SERVER_INFO}-api-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<maxHistory>7</maxHistory>
<totalSizeCap>100MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${WARN_LOG_PATTERN}</pattern>
</encoder>
</appender>

<appender name="API_ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/api/error-${SERVER_INFO}-api.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/api/error-${SERVER_INFO}-api-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<maxHistory>7</maxHistory>
<totalSizeCap>100MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${ERROR_LOG_PATTERN}</pattern>
</encoder>
</appender>
</included>
21 changes: 21 additions & 0 deletions src/main/resources/logback-dev.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="logback-appender.xml"/>

<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="CONSOLE_INFO_FILE"/>
<appender-ref ref="CONSOLE_WARN_FILE"/>
<appender-ref ref="CONSOLE_ERROR_FILE"/>
</root>

<!-- 추후 필터 구현 후 연결 예정-->
<!-- <logger name="Filter" level="INFO" additivity="false">-->
<!-- <appender-ref ref="API_INFO_FILE"/>-->
<!-- <appender-ref ref="API_WARN_FILE"/>-->
<!-- <appender-ref ref="API_ERROR_FILE"/>-->
<!-- </logger>-->

<logger name="org.hibernate" level="ERROR"/>
<logger name="org.springframework.web" level="INFO"/>
</configuration>
23 changes: 23 additions & 0 deletions src/main/resources/logback-local.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="logback-appender.xml"/>

<property name="LOG_PATH" value="~/info-local" />
<property name="SERVER_INFO" value="local" />

<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="CONSOLE_INFO_FILE"/>
<appender-ref ref="CONSOLE_WARN_FILE"/>
<appender-ref ref="CONSOLE_ERROR_FILE"/>
</root>

<!-- 추후 필터 구현 후 연결 예정-->
<!-- <logger name="Filter" level="INFO" additivity="false">-->
<!-- <appender-ref ref="API_CONSOLE"/>-->
<!-- <appender-ref ref="API_FILE"/>-->
<!-- </logger>-->

<logger name="org.hibernate" level="ERROR"/>
<logger name="org.springframework.web" level="INFO"/>
</configuration>
21 changes: 21 additions & 0 deletions src/main/resources/logback-prod.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="logback-appender.xml"/>

<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="CONSOLE_INFO_FILE"/>
<appender-ref ref="CONSOLE_WARN_FILE"/>
<appender-ref ref="CONSOLE_ERROR_FILE"/>
</root>

<!-- 추후 필터 구현 후 연결 예정&ndash;&gt;-->
<!-- <logger name="Filter" level="INFO" additivity="false">-->
<!-- <appender-ref ref="API_INFO_FILE"/>-->
<!-- <appender-ref ref="API_WARN_FILE"/>-->
<!-- <appender-ref ref="API_ERROR_FILE"/>-->
<!-- </logger>-->

<logger name="org.hibernate" level="ERROR"/>
<logger name="org.springframework.web" level="INFO"/>
</configuration>

0 comments on commit 516b7f2

Please sign in to comment.