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: slf4j 로그 설정 추가 및 적용 #17

Merged
merged 2 commits into from
Oct 27, 2024

Conversation

hanbirang
Copy link
Collaborator

@hanbirang hanbirang commented Oct 25, 2024

Pull requests

작업한 내용

application properties에 다음 내용을 추가해주세요!!!!

# log
spring.profiles.active=local
logging.config=classpath:logback-spring.xml
logging.file.path=./logs
  • 로그 설정을 위해 logback-spring.xml 설정 파일을 작성하였습니다.
    • 콘솔 및 파일 로그 출력 형식을 일관성 있게 적용하였습니다.
    • 로컬 환경에서는 console만 나오고, 개발 환경과 운영 환경에서는 콘솔과 더불어 파일까지 저장됩니다.
    • 개발환경의 설정에서 작업하고 로그 파일로 저장하고 싶다면 application.propertiesspring.profiles.active 부분을 dev로 수정하면 됩니다!
  • GlobalExceptionHandler 클래스 예외 처리가 필요한 파일에서 예외 처리 시 로깅을 적용하였습니다
  • console 찍을 일이 있다면 console 대신 log.info()로 찍어서 확인하시면 됩니다! 그 후 필요없는 로그는 지워주세요!

PR Point

  • 로깅 레벨(INFO, WARN, ERROR)이 적절히 설정되어 있는지 확인해 주세요.
  • 로그 메시지가 적절한 레벨로 기록되고 있는지, 그리고 필요한 정보가 포함되어 있는지 중점적으로 봐 주세요.
  • 추가적인 로깅 정보나 형식 개선에 대한 의견이 있으시면 말씀해주세요!!
  • 파일의 경우 전체적인 로그를 저장하는 파일과 에러 메시지만 저장하는 파일 두 가지를 생성합니다.
    • 파일의 최대 사이즈는 100MB이며, 최대 30일간의 로그 파일을 보관합니다
    • 로그 파일은 날짜별로 생성되며, 예를 들어 파일의 크기가 큰 경우 2024-10-25.0.log, 2024-10-25.1.log와 같은 형식으로 저장됩니다.

📸 스크린샷

사진 설명
image application.propertieslocaldev로 수정시 파일로 로그 저장

정보 공유 (로그 레벨)

  • Fatal
    • 매우 심각한 에러.
    • 프로그램이 종료되는 경우가 많음. (작성되지 않기 때문에 작성하지 않기도 함)
  • Error
    • 의도하지 않은 에러가 발생한 경우 (프로그램 내에서 개발자가 의도하지 않은 예외를 나타낼 때 사용)
    • 프로그램이 종료되진 않음
    • ex : 외부 api 요청에 에러가 발생한 경우
  • Warn
    • 에러가 될 수 있는 잠재적 가능성이 있는 경우
    • 이러한 로그가 발생했을 때 알람을 통해 개발자가 크리티컬한 에러를 맞닥뜨리기 전 해결할 수 있는 경우 사용
  • Info
    • 명확한 의도가 있는 에러
    • 요구사항에 따라 시스템 동작을 보여줄 때
  • Debug
    • Info 레벨보다 더 자세한 정보가 필요한 경우.
    • 개발 혹은 테스트 단계에서 해당 기능들이 올바르게 작동하는지 확인하기 위한 로그 레벨
  • Trace
    • Debug 레벨보다 더 자세함
    • Dev 환경에서 버그를 해결하기 위해 사용

closed #16

@hanbirang hanbirang requested a review from LEE-GYU-BIN October 25, 2024 05:18
@hanbirang hanbirang self-assigned this Oct 25, 2024
@hanbirang hanbirang linked an issue Oct 25, 2024 that may be closed by this pull request
3 tasks
Copy link
Contributor

@LEE-GYU-BIN LEE-GYU-BIN left a comment

Choose a reason for hiding this comment

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

감사합니다. 덕분에 이런거 설정 PR올려주실때마다 공부 많이 하고 있습니다. 수고하셨습니다!

@hanbirang hanbirang merged commit 91d5084 into main Oct 27, 2024
1 check passed
@hanbirang hanbirang deleted the feature/16-implement-logging-library branch October 27, 2024 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Logging Library
2 participants