-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(*): 모니터링을 위해 개발 환경에서 파일로 로깅 (#82)
* Refactor(*): 잘못된 주석 및 중복 표현 삭제 * Feat(*): 개발환경에 따라 다른 로깅 전략 구현 - 로컬 환경에서는 기본 콘솔 로그 설정 사용 - 개발 환경에서는 일반 로그와 sql 로그를 각각 다른 파일에 로깅하도록 설정 * Feat(*): 로그 경로를 환경변수로 처리 * Feat(*): 컨테이너 환경에서 elk 관련 및 자동화 설정 - CD 과정 중에 로그 관련 볼륨 (logsVolume) 추가 - script 폴더에 elk 관련 설정과 docker compose 파일 추가
- Loading branch information
Showing
11 changed files
with
131 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<!-- Spring Boot의 log.file.path 설정 읽기 --> | ||
<springProperty name="LOG_PATH" source="log.file.path"/> | ||
|
||
<!-- 일반 로그 파일 설정 --> | ||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>${LOG_PATH}/jabiseo.log</file> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<fileNamePattern>${LOG_PATH}/jabiseo.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
<maxHistory>30</maxHistory> | ||
</rollingPolicy> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<!-- SQL 로그 전용 파일 설정 --> | ||
<appender name="SQL_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>${LOG_PATH}/jabiseo_sql.log</file> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<fileNamePattern>${LOG_PATH}/jabiseo_sql.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
<maxHistory>30</maxHistory> | ||
</rollingPolicy> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
<charset>UTF-8</charset> | ||
</encoder> | ||
</appender> | ||
|
||
<!-- 루트 로거: 일반 로그를 파일에만 기록 --> | ||
<root level="INFO" additivity="false"> | ||
<appender-ref ref="FILE"/> | ||
</root> | ||
|
||
<!-- Hibernate SQL 로그를 별도 파일에만 기록 --> | ||
<logger name="org.hibernate.SQL" level="DEBUG" additivity="false"> | ||
<appender-ref ref="SQL_FILE"/> | ||
</logger> | ||
|
||
<!-- Hibernate의 다른 내부 로거는 비활성화 --> | ||
<logger name="org.hibernate" level="OFF"/> | ||
|
||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<!-- 로컬 환경에서는 Spring Boot 기본 콘솔 로그 설정 사용 --> | ||
<springProfile name="local"> | ||
<include resource="org/springframework/boot/logging/logback/base.xml"/> | ||
</springProfile> | ||
|
||
<!-- dev 환경에서는 logback-dev.xml 설정 사용 --> | ||
<springProfile name="dev"> | ||
<include resource="logback-dev.xml"/> | ||
</springProfile> | ||
|
||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
services: | ||
|
||
filebeat: | ||
container_name: filebeat | ||
hostname: filebeat | ||
image: docker.elastic.co/beats/filebeat:8.15.0 | ||
networks: | ||
- jabiseo-dev | ||
volumes: | ||
- "./filebeat.yml:/usr/share/filebeat/filebeat.yml" | ||
- logsVolume:/logs | ||
|
||
logstash: | ||
container_name: logstash | ||
hostname: logstash | ||
image: opensearchproject/logstash-oss-with-opensearch-output-plugin:8.9.0 | ||
networks: | ||
- jabiseo-dev | ||
ports: | ||
- 5044:5044 | ||
volumes: | ||
- "./logstash.conf:/usr/share/logstash/pipeline/logstash.conf" | ||
|
||
volumes: | ||
logsVolume: | ||
external: true | ||
name: logsVolume | ||
|
||
networks: | ||
jabiseo-dev: | ||
external: true | ||
name: jabiseo-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
filebeat.inputs: | ||
- type: log | ||
enabled: true | ||
paths: | ||
- /logs/*.log | ||
|
||
output.logstash: | ||
hosts: ["logstash:5044"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
input { | ||
beats { | ||
port => 5044 | ||
} | ||
} | ||
|
||
output { | ||
opensearch { | ||
hosts => [""] ; OpenSearch URL | ||
user => "" ; OpenSearch Username | ||
password => ; // OpenSearch Password | ||
index => "logstash-logs-%{+YYYY.MM.dd}" | ||
ecs_compatibility => disabled | ||
} | ||
} |