Skip to content
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

feat: 로깅 적용 #34

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

feat: 로깅 적용 #34

wants to merge 3 commits into from

Conversation

dani820
Copy link
Collaborator

@dani820 dani820 commented Oct 6, 2024

이 PR을 통해 해결하려는 문제

  • 적절한 로깅 전략을 수립하고 적용함으로써 문제 발생 시 명확하고 빠르게 파악할 수 있도록 한다.
  • log4j2 같은 로깅 프레임워크를 통해 필요한 정보들을 출력 가능하나, MDC를 사용함으로써 멀티 스레드 환경에서 모든 요청을 명확히 식별하고 체계적으로 관리할 수 있도록 한다.

추가 및 변경사항

  • log4j2 적용 및 로깅 필터 구현
  • MDC 적용 (스레드 별로 요청 id 와 사용자 id 정보 포함)

참고(옵션)

  • 로깅 패턴
    [%equals{%X{requestId}}{}{startup}][%d{yyyy-MM-dd HH:mm:ss}:%-4relative] [%c] [%X{userId}] - %m%n
    json 형식으로 변경. 템플릿 파일 생성하여 requestId, timestamp, logger, userId, message, exception 순으로 출력되도록 패턴 작성

  • 실행 예시

    • 애플리케이션 처음 실행 시에는 필터를 거치지 않으므로 요청 id 가 없어 빈 값으로 찍히지 않도록 기본값으로 'startup'을 지정 참고
      스크린샷 2024-10-08 오전 1 18 44
    • 요청 수행 시 요청 id 와 사용자 id 를 포함한 정보 표출
      스크린샷 2024-10-08 오전 1 19 10

체크리스트

  • 리뷰어를 지정하였는가
  • 코드가 오류나 경고없이 빌드되는가
  • 추가 및 변경된 사항에 대해 충분히 테스트 하였는가

@dani820 dani820 self-assigned this Oct 6, 2024
Copy link
Collaborator

@f-lab-bradley f-lab-bradley left a comment

Choose a reason for hiding this comment

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

Log 형식을 Json 으로 하는건 어떨까요???

@dani820
Copy link
Collaborator Author

dani820 commented Oct 7, 2024

넵 수정하겠습니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants