-
Notifications
You must be signed in to change notification settings - Fork 1
Spring AOP + Logback 로깅 시스템 적용 #793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
기존의 가독성 떨어지는 StackTrace 제거 및 이모지 추가 Related to: #782
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로깅 시스템 개선 작업 하시느라 너무 고생 많으셨습니다!!
모든 요청에 대한 로그 트래킹이 훨씬 간편해지고, 가시성 또한 좋아질 것 같네용
AOP 기반으로 처리한 부분또한 되게 인상적이네요ㄷㄷ
감사합니다~~~
StackTraceElement firstTrace = exception.getStackTrace()[0]; | ||
errorLog.put("errorLocation", | ||
String.format("%s.%s:%d", | ||
firstTrace.getClassName(), | ||
firstTrace.getMethodName(), | ||
firstTrace.getLineNumber() | ||
) | ||
); |
There was a problem hiding this comment.
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) {}
제가 파악한 요청 처리 순서는 다음과 같은데,
- 요청 들어옴
- RequestIdFilter
- HttpLoggingAspect - Around()
→ logRequest() 실행 - 실제 Controller 메서드 실행
→ Exception 발생 - HttpLoggingAspect의 catch 블록
→ logError() 실행 - 예외 throw error
- GlobalExceptionHandler 실행
위에서 말씀드린 예외처리가 없다면 5번 logError() 처리 중에
stackTrace 가 없으면, ArrayIndexOutOfBoundsException 오류가 날 것 같아요!
🐬 요약
Spring AOP + Logback 로깅 시스템 적용
👻 유형
PR의 유형에 맞게 체크해주세요!
🍀 작업 내용
PR에 담긴 작업 내용을 작성해주세요!
🌟 관련 이슈
해당 기능 배포전에 yml에 존재하는 tomcat accesslog 관련 설정을 지워야합니다 (dev + prod)
컨트롤러에 들어오는 request와 그에 따른 response나 error가 모두 관리되기때문에 중복해서 로그를 생성할 필요가 없습니다.
close: #782