Skip to content

Commit

Permalink
Merge pull request #123 from MYONGSIK/infra/monitoring
Browse files Browse the repository at this point in the history
#122 ๋กœ๊ทธ ๋ชจ๋‹ˆํ„ฐ๋ง ๊ตฌ์ถ• ์™„๋ฃŒ
  • Loading branch information
Qbeom0925 authored Jun 6, 2023
2 parents 2d9de1e + 6603276 commit 22854c1
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.7.4'
implementation 'org.springframework.boot:spring-boot-starter-logging'

// mongo
// implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ spring:
url: ENC(jV5Al684UF9ZuGwX0AJ4KaAl2djrcg5+mZe+QMgY1i2Afu6rtj0Cmrj52fkzjiQAP3b31dyhrLvggD+Mold//xi+7WPdEEu7AjoO1XGbMNl5uf5hKMhUh5pmZDpCkubJgj/VFoVUe4s=)
username: ENC(W14O0+528BmR05t/tOqkJA==)
password: ENC(8K7aplBAKgyNF7OuP11M6cXlCT1zLzm4)
driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: com.mysql.cj.jdbc.Driver
log:
config:
path: ./logs
filename: app-dev
maxHistory: 7 # 7์ผ
totalSizeCap: 10MB # ๋กœ๊ทธ ํŒŒ์ผ ์‚ฌ์ด์ฆˆ
8 changes: 7 additions & 1 deletion src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ spring:
url: ENC(rMxUsofvraIkaMgSRzwu8g6UfnSv1t+I57CAt4Id+qR0Woi/yGJ/dAyT6+KqF/McGN7uSI8aYef1DuWJu13N+1iHbFTfQZbDNalt8A3Lm4MwU0MxUA7o0qf+DU0043KdS8wag3pNGwA=)
username: ENC(AtyIP2KxL11MVrdq2yBI9Q==)
password: ENC(dc0+G3VP0z9eZQ+vZZg49KFbrCubCsQj)
driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: com.mysql.cj.jdbc.Driver
log:
config:
path: /var/log/app
filename: app-dev
maxHistory: 3 # 3์ผ
totalSizeCap: 50MB # ๋กœ๊ทธ ํŒŒ์ผ ์‚ฌ์ด์ฆˆ
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ spring:
---
spring:
profiles:
active: local
active: local
59 changes: 59 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- ๋กœ๊ทธ ํŒจํ„ด์— ์ƒ‰์ƒ ์ ์šฉ %clr(pattern){color}
https://logback.qos.ch/manual/layouts.html#coloring
-->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />

<springProfile name="dev">
<property resource="application-dev.yml" />
</springProfile>

<!-- log ๋ณ€์ˆ˜ ๊ฐ’ ์„ค์ • -->
<springProperty name="LOG_PATH" source= "log.config.path" />
<springProperty name="LOG_FILE_NAME" source= "log.config.filename" />
<springProperty name="LOG_MAX_HISTORY" source= "log.config.maxHistory" />
<springProperty name="LOG_TOTAL_SIZE_CAP" source= "log.config.totalSizeCap" />

<property name="CONSOLE_LOG_PATTERN"
value="[%d{yyyy-MM-dd HH:mm:ss}:%-3relative] %clr(%-5level) %clr(${PID:-}){magenta} %clr(---){faint} %clr([%15.15thread]){faint} %clr(%-40.40logger{36}){cyan} %clr(:){faint} %msg%n"/>
<property name="FILE_LOG_PATTERN"
value="[%d{yyyy-MM-dd HH:mm:ss}:%-3relative] %-5level ${PID:-} --- [%15.15thread] %-40.40logger{36} : %msg%n"/>

<!-- ์ฝ˜์†”(STDOUT) -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
</layout>
</appender>

<!-- ํŒŒ์ผ(FILE) -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- log ๊ธฐ๋กํ•  ํŒŒ์ผ ์œ„์น˜ ์„ค์ • -->
<file>${LOG_PATH}/${LOG_FILE_NAME}.log</file>
<!-- log ๊ธฐ๋ก ํƒ€์ž… ์ธ์ฝ”๋”ฉ -->
<encoder>
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${LOG_PATH}/${LOG_FILE_NAME}.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>${LOG_MAX_HISTORY}</maxHistory>
<totalSizeCap>${LOG_TOTAL_SIZE_CAP}</totalSizeCap>
</rollingPolicy>
</appender>

<!-- spring profile๋ณ„ ๋กœ๊ทธ ์„ค์ • -->
<!-- dev ํ™˜๊ฒฝ -->
<springProfile name="dev">
<root level="info">
<!-- ์ฐธ์กฐํ•  appender - STDOUT -->
<appender-ref ref="STDOUT" />
</root>
<logger name="org.springframework.web" level="debug">
<!-- ์ฐธ์กฐํ•  appender - FILE -->
<appender-ref ref="FILE" />
</logger>
</springProfile>

</configuration>

0 comments on commit 22854c1

Please sign in to comment.