Skip to content

Commit

Permalink
[Feat/#135] 로그 모니터링 환경 구축 (#164)
Browse files Browse the repository at this point in the history
* feat: logback 설정 추가

* feat: docker-compose에 log volume 설정
  • Loading branch information
belljun3395 authored Jul 8, 2024
1 parent 30af305 commit 6a73076
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
49 changes: 49 additions & 0 deletions api/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration debug="true">
<property resource="application.yml"/>

<springProperty name="LOGS_ABSOLUTE_PATH" source="log.file.path"/>

<include resource="org/springframework/boot/logging/logback/defaults.xml"/>

<appender name="API_ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${LOGS_ABSOLUTE_PATH}/%d/%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>

<springProfile name="prd">
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
<logger name="com.few" level="DEBUG">
<appender-ref ref="API_ROLLING"/>
</logger>
<logger name="org.jooq" level="DEBUG">
<appender-ref ref="API_ROLLING"/>
</logger>
<logger name="org.springframework" level="INFO">
<appender-ref ref="API_ROLLING"/>
</logger>
</springProfile>

<springProfile name="local">
<root level="DEBUG">
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>

</configuration>
2 changes: 2 additions & 0 deletions resources/docker/docker-compose-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
image: fewletter/api:latest
ports:
- "8080:8080"
volumes:
- /var/log/api:/var/log/api
environment:
SPRING_PROFILES_ACTIVE: ${API_SPRING_PROFILES_ACTIVE}
DB_HOSTNAME: ${DB_HOSTNAME}
Expand Down

0 comments on commit 6a73076

Please sign in to comment.