Skip to content

chore: AOP Logging 구현#478

Merged
woogieon8on merged 10 commits intodevfrom
chore/477-aop-logging
Jul 9, 2025
Merged

chore: AOP Logging 구현#478
woogieon8on merged 10 commits intodevfrom
chore/477-aop-logging

Conversation

@woogieon8on
Copy link
Member

@woogieon8on woogieon8on commented Jul 8, 2025

🌱 관련 이슈

close #477

📌 작업 내용 및 특이사항

  • 이벤트(Publisher, Handler), 컨트롤러, 서비스, 레포지토리 레이어에 각각 AOP를 적용하여 로깅을 구현하였습니다.
  • 정상 응답에 대해 '레이어, 메서드명, 소요 시간'을 기록합니다.
  • 예외처리에 대해 '예외 구분, 메서드명, 예외 클래스, 메세지, 소요 시간'을 기록합니다.
  • 이벤트, 서비스 레이어에서 발생하는 GeneralException은 로그 레벨을 info로 설정하고, 기타 Exception에 대해서는 error로 설정하였습니다.
  • LoggingUtil 클래스를 구현하여 traceId 생성, 조회 등 로깅에 필요한 기능을 담당하도록 하였습니다.

📝 참고사항

  • 레포지토리는 Spring Data JPA가 내부적으로 프록시를 생성하고 위임하기 때문에 Custom 구현체도 프록시 흐름에 들어가 Pointcut에 포함되는 문제가 있어, RepositoryImpl의 메서드에 대해서만 로깅하도록 Pointcut을 설정했습니다.

📚 기타

  • 정상 응답 로깅(인텔리제이)
    image

  • 정상 응답 로깅(그라파나)
    image

  • 예외처리 로깅(인텔리제이)
    image

  • 예외처리 로깅(그라파나)
    image

@woogieon8on woogieon8on added the 🔧 Chore 개발 환경 설정 label Jul 8, 2025
Comment on lines 60 to 67
} catch (GeneralException generalException) {
log.info(
"[EVENT-LISTENER-CUSTOM] Method: {}, Code: {}, Message: {}, Duration: {}ms",
methodName,
generalException.getErrorStatus().getCode(),
generalException.getMessage(),
calculateDuration(start));
throw generalException;
Copy link
Member

Choose a reason for hiding this comment

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

EvnetHandler에서 생기는 GeneralException 은 서비스에서 동일하게 생겨서 중복으로 로그를 남길지 논의가 필요할거같습니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

GeneralException은 서비스에서만 로그를 남기는게 좋은 것 같습니다! 수정할게요

@jeongyeon0208 jeongyeon0208 self-requested a review July 9, 2025 08:05
Copy link
Member

@jeongyeon0208 jeongyeon0208 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@woogieon8on woogieon8on merged commit ad67b41 into dev Jul 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔧 Chore 개발 환경 설정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🔧 AOP 로깅 설정

2 participants