<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>[%d{yyyy-MM-dd HH:mm:ss}:%-3relative][%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./logs/logback.log</file>
<encoder>
<pattern>[%d{yyyy-MM-dd HH:mm:ss}:%-3relative][%thread] %-5level %logger{35} - %msg%n</pattern> <!-- ํด๋น ํจํด ๋ค์ด๋ฐ์ผ๋ก ํ์ฌ ๋ก๊ทธ๊ฐ ๊ธฐ๋ก๋จ -->
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>./was-logs/info.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern> <!-- ํด๋น ํจํด ๋ค์ด๋ฐ์ผ๋ก ์ด์ ํ์ผ์ด ๊ธฐ๋ก๋จ -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize> <!-- ํ ํ์ผ์ ์ต๋ ์ฉ๋ -->
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>30</maxHistory> <!-- ํ ํ์ผ์ ์ต๋ ์ ์ฅ ๊ธฐํ -->
</rollingPolicy>
</appender>
<!-- <root level="INFO">-->
<!-- <appender-ref ref="STDOUT" />-->
<!-- </root>-->
<!-- file์ ์ฐํ ๋ก๊ทธ -->
<logger name="com.dot3company">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<logger name="org.springframework.web">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
</configuration>
JSON ์ผ๋ก ๋ก๊ทธํ์ผ ์ถ๋ ฅ
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>[%d{yyyy-MM-dd HH:mm:ss}] [%thread{10}] [%X{traceId:-}] [%-5level] [%logger{0}:%line] - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>./logs/logback.log</file>
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/><!-- json ํํ๋ก ํ์ผ์ ๋ก๊ทธ ๋จ๊น -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>./was-logs/info.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern> <!-- ํด๋น ํจํด ๋ค์ด๋ฐ์ผ๋ก ์ด์ ํ์ผ์ด ๊ธฐ๋ก๋จ -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize> <!-- ํ ํ์ผ์ ์ต๋ ์ฉ๋ -->
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>30</maxHistory> <!-- ํ ํ์ผ์ ์ต๋ ์ ์ฅ ๊ธฐํ -->
</rollingPolicy>
</appender>
<!-- <root level="INFO">-->
<!-- <appender-ref ref="STDOUT" />-->
<!-- </root>-->
<!-- file์ ์ฐํ ๋ก๊ทธ -->
<logger name="com.dot3company">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<logger name="org.springframework.web">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
</configuration>