Skip to content

Commit

Permalink
feat : #155 logback 설정
Browse files Browse the repository at this point in the history
- hibernate sql, security DEBUG 로그 출력하도록 설정
  • Loading branch information
tnals2384 committed Sep 16, 2024
1 parent ab9510e commit 348302e
Show file tree
Hide file tree
Showing 2 changed files with 189 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config
188 changes: 188 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<property name="INFO_LOG_FILE_NAME_PATTERN" value="./logs/qapple-info-%d{yyyy-MM-dd, Asia/Seoul}.%i.log" />
<property name="ERROR_LOG_FILE_NAME_PATTERN" value="./logs/qapple-error-%d{yyyy-MM-dd, Asia/Seoul}.%i.log" />
<property name="WARN_LOG_FILE_NAME_PATTERN" value="./logs/qapple-warn-%d{yyyy-MM-dd, Asia/Seoul}.%i.log" />
<property name="DEBUG_LOG_FILE_NAME_PATTERN" value="./logs/qapple-debug-%d{yyyy-MM-dd, Asia/Seoul}.%i.log" />
<property name="TRACE_LOG_FILE_NAME_PATTERN" value="./logs/qapple-trace-%d{yyyy-MM-dd, Asia/Seoul}.%i.log" />

<property name="INFO_LOG_PATTERN" value="%d{yy-MM-dd} %d{HH:mm:ss.SSS} %boldGreen(%+5p) --- %magenta([%t]) %cyan(%logger) - %m%n"/>
<property name="ERROR_LOG_PATTERN" value="%d{yy-MM-dd} %d{HH:mm:ss.SSS} %boldRed(%+5p) --- %magenta([%t]) %cyan(%logger) - %m%n"/>
<property name="WARN_LOG_PATTERN" value="%d{yy-MM-dd} %d{HH:mm:ss.SSS} %boldYellow(%+5p) --- %magenta([%t]) %cyan(%logger) - %m%n"/>
<property name="DEBUG_LOG_PATTERN" value="%d{yy-MM-dd} %d{HH:mm:ss.SSS} %boldBlue(%+5p) --- %magenta([%t]) %cyan(%logger) - %m%n"/>
<property name="TRACE_LOG_PATTERN" value="%d{yy-MM-dd} %d{HH:mm:ss.SSS} %gray(%+5p) --- %magenta([%t]) %cyan(%logger) - %m%n"/>

<property name="MAX_FILE_SIZE" value="10MB" />
<property name="TOTAL_SIZE" value="300MB" />
<property name="MAX_HISTORY" value="30" />

<appender name="INFO_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf8</charset>
<Pattern>${INFO_LOG_PATTERN}</Pattern>
</encoder>
</appender>
<appender name="ERROR_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf8</charset>
<Pattern>${ERROR_LOG_PATTERN}</Pattern>
</encoder>
</appender>
<appender name="WARN_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf8</charset>
<Pattern>${WARN_LOG_PATTERN}</Pattern>
</encoder>
</appender>
<appender name="DEBUG_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf8</charset>
<Pattern>${DEBUG_LOG_PATTERN}</Pattern>
</encoder>
</appender>
<appender name="TRACE_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>TRACE</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf8</charset>
<Pattern>${TRACE_LOG_PATTERN}</Pattern>
</encoder>
</appender>

<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./log/qapple-info.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf8</charset>
<pattern>${INFO_LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${INFO_LOG_FILE_NAME_PATTERN}</fileNamePattern>
<maxHistory>${MAX_HISTORY}</maxHistory>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<totalSizeCap>${TOTAL_SIZE}</totalSizeCap>
</rollingPolicy>
</appender>
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./log/qapple-error.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf8</charset>
<pattern>${ERROR_LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${ERROR_LOG_FILE_NAME_PATTERN}</fileNamePattern>
<maxHistory>${MAX_HISTORY}</maxHistory>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<totalSizeCap>${TOTAL_SIZE}</totalSizeCap>
</rollingPolicy>
</appender>
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./log/qapple-warn.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf8</charset>
<pattern>${WARN_LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${WARN_LOG_FILE_NAME_PATTERN}</fileNamePattern>
<maxHistory>${MAX_HISTORY}</maxHistory>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<totalSizeCap>${TOTAL_SIZE}</totalSizeCap>
</rollingPolicy>
</appender>
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./log/qapple-debug.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf8</charset>
<pattern>${DEBUG_LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${DEBUG_LOG_FILE_NAME_PATTERN}</fileNamePattern>
<maxHistory>${MAX_HISTORY}</maxHistory>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<totalSizeCap>${TOTAL_SIZE}</totalSizeCap>
</rollingPolicy>
</appender>
<appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./log/qapple-trace.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>TRACE</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf8</charset>
<pattern>${TRACE_LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${TRACE_LOG_FILE_NAME_PATTERN}</fileNamePattern>
<maxHistory>${MAX_HISTORY}</maxHistory>
<maxFileSize>${MAX_FILE_SIZE}</maxFileSize>
<totalSizeCap>${TOTAL_SIZE}</totalSizeCap>
</rollingPolicy>
</appender>

<logger name="org.hibernate.SQL" level="DEBUG" additivity="false">
<appender-ref ref="DEBUG_CONSOLE"/>
<appender-ref ref="DEBUG_FILE"/>
</logger>

<logger name="org.springframework.security" level="DEBUG" additivity="false">
<appender-ref ref="DEBUG_CONSOLE"/>
<appender-ref ref="DEBUG_FILE"/>
</logger>

<root level="INFO">
<appender-ref ref="INFO_CONSOLE"/>
<appender-ref ref="ERROR_CONSOLE"/>
<appender-ref ref="WARN_CONSOLE"/>
<appender-ref ref="DEBUG_CONSOLE"/>
<appender-ref ref="TRACE_CONSOLE"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="ERROR_FILE"/>
<appender-ref ref="WARN_FILE"/>
<appender-ref ref="DEBUG_FILE"/>
<appender-ref ref="TRACE_FILE"/>
</root>
</configuration>

0 comments on commit 348302e

Please sign in to comment.