From 6603276e56aa94016a6704833dab3fb00e506781 Mon Sep 17 00:00:00 2001 From: kyubeom Date: Tue, 6 Jun 2023 21:23:09 +0900 Subject: [PATCH] =?UTF-8?q?#122=20=EB=A1=9C=EA=B7=B8=20=EB=AA=A8=EB=8B=88?= =?UTF-8?q?=ED=84=B0=EB=A7=81=20=EA=B5=AC=EC=B6=95=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - prod 환경에서 /var/log/app 경로에 저장합니다. --- build.gradle | 1 + src/main/resources/application-dev.yml | 8 +++- src/main/resources/application-prod.yml | 8 +++- src/main/resources/application.yml | 2 +- src/main/resources/logback-spring.xml | 59 +++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/logback-spring.xml diff --git a/build.gradle b/build.gradle index 5c13c04..60065e1 100644 --- a/build.gradle +++ b/build.gradle @@ -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' diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 621940a..7cefb65 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -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 \ No newline at end of file + driver-class-name: com.mysql.cj.jdbc.Driver +log: + config: + path: ./logs + filename: app-dev + maxHistory: 7 # 7일 + totalSizeCap: 10MB # 로그 파일 사이즈 \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index a186cb4..fb2f503 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -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 \ No newline at end of file + driver-class-name: com.mysql.cj.jdbc.Driver +log: + config: + path: /var/log/app + filename: app-dev + maxHistory: 3 # 3일 + totalSizeCap: 50MB # 로그 파일 사이즈 \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fb00f58..e1788ef 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -55,4 +55,4 @@ spring: --- spring: profiles: - active: local + active: local \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..ae5e0fa --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + + ${LOG_PATH}/${LOG_FILE_NAME}.log + + + ${FILE_LOG_PATTERN} + + + + ${LOG_PATH}/${LOG_FILE_NAME}.%d{yyyy-MM-dd}.log + ${LOG_MAX_HISTORY} + ${LOG_TOTAL_SIZE_CAP} + + + + + + + + + + + + + + + + + \ No newline at end of file