Skip to content

Commit

Permalink
[BE] Fix/#366 테스트 수행 시 로그 패턴 깨지는 오류 해결 (#367)
Browse files Browse the repository at this point in the history
* fix: 테스트 로그 패턴 설정 오류 수정

- 잘못된 로그 패턴 설정으로 인한 'LOG_PATTERN IS_UNDEFINED' 메시지 출력 오류 수정

* chore: 프론트엔드, 백엔드 develop 분리에 따른 워크플로우 수정

* fix: 테스트 로그 설정 파일명 변경
- springProperty 지원을 위해 파일명 변경

* feat: 로그 내용 및 설정 보완(색상 적용)

- 로그에서 로거, 레벨, PID 확인 가능하도록 내용 보완
- 테스트 로그의 경우 프로젝트 패키지에 해당하는 로그만 DEBUG 레벨로 설정
- 콘솔 로그 색상 적용

* feat: 로그 내용 보완 - 스레드 출력하도록 수정
  • Loading branch information
yoondgu authored Sep 1, 2023
1 parent 388386c commit 731f0fa
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/be-merge-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:

pull_request:
branches: [ develop ]
branches: [ develop-BE ]
types: [ closed ]
paths: backend/**

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/be-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:

pull_request:
branches: [ main, develop ]
branches: [ main, develop-BE ]
paths: backend/**

permissions:
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ logging:
# jar 파일 실행 시, jar 파일과 동일한 디렉토리 내 log 디렉토리에 생성됨
path: /home/ubuntu/backend/build/log
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss.SSS} %msg %n"
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} %msg %n"
console: "%green(%d{yyyy-MM-dd HH:mm:ss.SSS}) [%thread] ${PID} %highlight(%5level) %cyan(%logger) - %msg%n"
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] ${PID} %5level %logger - %msg%n"

oauth:
kakao:
Expand Down
5 changes: 2 additions & 3 deletions backend/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ spring:

logging:
file:
# jar 파일 실행 시, jar 파일과 동일한 디렉토리 내 log 디렉토리에 생성됨
path: /home/ubuntu/backend/build/log
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss.SSS} %msg %n"
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} %msg %n"
console: "%green(%d{yyyy-MM-dd HH:mm:ss.SSS}) [%thread] ${PID} %highlight(%5level) %cyan(%logger) - %msg%n"
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] ${PID} %5level %logger - %msg%n"

oauth:
kakao:
Expand Down
5 changes: 2 additions & 3 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ logging:
sql:
BasicBinder: TRACE
file:
# jar 파일 실행 시, jar 파일과 동일한 디렉토리 내 log 디렉토리에 생성됨
path: ./log
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss.SSS} %msg %n"
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} %msg %n"
console: "%green(%d{yyyy-MM-dd HH:mm:ss.SSS}) [%thread] ${PID} %highlight(%5level) %cyan(%logger) - %msg%n"
file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] ${PID} %5level %logger - %msg%n"

oauth:
kakao:
Expand Down
17 changes: 8 additions & 9 deletions backend/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<configuration>
<springProperty name="LOG_PATH" source="logging.file.path"/>
<springProperty name="LOG_PATTERN" source="logging.pattern.file"/>
<springProperty name="FILE_LOG_PATTERN" source="logging.pattern.file"/>
<springProperty name="CONSOLE_LOG_PATTERN" source="logging.pattern.console"/>

<timestamp key="DateFormat" datePattern="yyyy-MM-dd"/>

<!-- 콘솔 로그 설정 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
${LOG_PATTERN}
</Pattern>
</layout>
<encoder>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
</encoder>
</appender>

Expand All @@ -24,7 +23,7 @@
</filter>
<file>${LOG_PATH}/warn.log</file>
<encoder>
<pattern>${LOG_PATTERN}</pattern>
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
</appender>

Expand All @@ -38,7 +37,7 @@

<file>${LOG_PATH}/error.log</file>
<encoder>
<pattern>${LOG_PATTERN}</pattern>
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
</appender>

Expand Down
4 changes: 1 addition & 3 deletions backend/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ spring:
logging:
level:
org.hibernate.orm.jdbc.bind: trace
org.hibernate.type: trace
org.hibernate.stat: debug
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss.SSS} %msg %n"
console: "%green(%d{yyyy-MM-dd HH:mm:ss.SSS}) [%thread] ${PID} %highlight(%5level) %cyan(%logger) - %msg%n"

oauth:
kakao:
Expand Down
19 changes: 19 additions & 0 deletions backend/src/test/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<configuration>
<springProperty name="LOG_PATTERN" source="logging.pattern.console"/>

<!-- 콘솔 로그 설정 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
${LOG_PATTERN}
</pattern>
</encoder>
</appender>

<!-- 프로젝트 패키지에 해당하는 로그만 DEBUG 레벨로 설정 (라이브러리 DEBUG 로그 제외) -->
<logger name="com.mapbefine.mapbefine" level="DEBUG" />
<!-- 레벨 별 Appender 적용 -->
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
17 changes: 0 additions & 17 deletions backend/src/test/resources/logback-test.xml

This file was deleted.

0 comments on commit 731f0fa

Please sign in to comment.