Skip to content

Conversation

dev-Crayon
Copy link
Contributor

@dev-Crayon dev-Crayon commented Oct 21, 2025

🐬 요약

Spring AOP + Logback 로깅 시스템 적용

👻 유형

PR의 유형에 맞게 체크해주세요!

  • 버그 수정
  • 기능 개발
  • 코드 스타일 수정 (formatting, local variables)
  • 리팩토링 (no functional changes, no api changes)
  • 빌드 관련 변경사항
  • CI 관련 변경사항
  • CD 관련 변경사항
  • 문서 내용 변경
  • Release
  • 기타... (다음 줄에 사유를 입력해주세요)

🍀 작업 내용

PR에 담긴 작업 내용을 작성해주세요!

  • Spring AOP 로깅 적용
  • Logback 파일 설정

🌟 관련 이슈

해당 기능 배포전에 yml에 존재하는 tomcat accesslog 관련 설정을 지워야합니다 (dev + prod)
컨트롤러에 들어오는 request와 그에 따른 response나 error가 모두 관리되기때문에 중복해서 로그를 생성할 필요가 없습니다.

close: #782

Spring AOP 의존성 추가
logback-spring.xml 파일 및 구현

Related to: #782
로깅 시 민감 필드 마스킹 처리를 위한 클래스 생성

Related to: #782
logback marker 의존성 추가
request별 트래킹을 위한 id생성 필터 추가
LoggingAspect 클래스 구현

Related to: #782
LogginAspect logError 메소드 정의

Related to: #782
@dev-Crayon dev-Crayon requested a review from Lim-Changi October 21, 2025 05:49
@dev-Crayon dev-Crayon self-assigned this Oct 21, 2025
@dev-Crayon dev-Crayon added medium priority 적절한 우선순위 요청 작업 승헌✏️ 승헌이 연 PR, Issue에 사용 ✨Feature 새로운 기능 개발시 사용합니다 labels Oct 21, 2025
기존의 가독성 떨어지는 StackTrace 제거 및 이모지 추가

Related to: #782
Copy link
Member

@Lim-Changi Lim-Changi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로깅 시스템 개선 작업 하시느라 너무 고생 많으셨습니다!!

모든 요청에 대한 로그 트래킹이 훨씬 간편해지고, 가시성 또한 좋아질 것 같네용

AOP 기반으로 처리한 부분또한 되게 인상적이네요ㄷㄷ
감사합니다~~~

Comment on lines +125 to +132
StackTraceElement firstTrace = exception.getStackTrace()[0];
errorLog.put("errorLocation",
String.format("%s.%s:%d",
firstTrace.getClassName(),
firstTrace.getMethodName(),
firstTrace.getLineNumber()
)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분에서 GlobalExceptionHandler 와 동일하게 아래와 같은 예외 처리가 필요할 것 같습니다!

 if (exception.getStackTrace().length == 0) {}

제가 파악한 요청 처리 순서는 다음과 같은데,

  1. 요청 들어옴
  2. RequestIdFilter
  3. HttpLoggingAspect - Around()
    → logRequest() 실행
  4. 실제 Controller 메서드 실행
    → Exception 발생
  5. HttpLoggingAspect의 catch 블록
    → logError() 실행
  6. 예외 throw error
  7. GlobalExceptionHandler 실행

위에서 말씀드린 예외처리가 없다면 5번 logError() 처리 중에
stackTrace 가 없으면, ArrayIndexOutOfBoundsException 오류가 날 것 같아요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨Feature 새로운 기능 개발시 사용합니다 medium priority 적절한 우선순위 요청 작업 size/L 승헌✏️ 승헌이 연 PR, Issue에 사용

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] 로그 파일 / 모니터링 체계화

2 participants