Skip to content

feat: logback 롤링 도입#2020

Merged
Soundbar91 merged 5 commits into
developfrom
feat/2019-logback-file-rolling
Oct 1, 2025
Merged

feat: logback 롤링 도입#2020
Soundbar91 merged 5 commits into
developfrom
feat/2019-logback-file-rolling

Conversation

@Soundbar91
Copy link
Copy Markdown
Collaborator

@Soundbar91 Soundbar91 commented Sep 30, 2025

🔍 개요

Image image
  • 코인 프로젝트는 logs/app.log에 INFO 레벨 이상의 로그를 찍고 있음
  • 하나의 파일에 지속적으로 로그를 찍고 있다보니, 파일의 용량이 커지고 있는 상황
    • 2025년 9월 30일 기준 : 스테이지 (약 235MB), 프로덕션 (약 12.37GB)
  • 최근 발생하고 있는 EC2 용량 부족 문제 해결과 향후 로그를 확인하는 과정에서 발생할 수 있는 불편함을 해소하기 위해 logback 파일 롤링 도입

🚀 주요 변경 내용

Appender 수정

  • Appender를 FileAppender에서 RollingFileAppender으로 수정했습니다.
  • RollingPolicy의 경우 한 달을 주기로 롤링, 최대 12개까지 보관할 수 있도록 설정했습니다.
  • 롤링된 파일은 .gz으로 압축해서 관리됩니다.

💬 참고 사항

  • Appender : log의 출력 대상과 형식을 설정

    • ConsoleAppender : 콘솔에 로그를 출력
    • FileAppender : 파일에 로그를 저장
    • RollingFileAppender : 여러개의 파일로 순환 저장 (FileAppender 상속)
    • SMTPAppender : 로그를 메일로 보낸다.
    • DBAppender : DB에 로그를 쌓는다.
  • RollingPolicy : 로그 보관 정책

    • TimeBasedRollingPolicy : 시간을 기준으로 롤링
    • SizeAndTimeBasedRollingPolicy : 시간을 기준으로 롤링하면서 용량 제한 가능
    • FixedWindowRollingPolicy : 파일 번호를 붙여 롤링
    • 속성 : maxHistory(보관 기간/개수), totalSizeCap(전체 보관 용량 제한)
  • TriggeringPolicy : 롤링 트리거

    • SizeBasedTriggeringPolicy : 로그 파일 크기가 임계치를 넘기면 트리거 발생
    • TimeBasedRollingPolicy와 SizeAndTimeBasedRollingPolicy의 경우 TriggeringPolicy를 내장하고 있음
  • 용량 제한을 걸지 않은 이유는 달마다 롤링을 했을 때 로그 파일의 용량이 그렇게 크지 않을것으로 예상했기 때문입니다.

  • 후속작업으로 aws s3 sync으로 s3 적재해볼 생각입니다.


✅ Checklist (완료 조건)

  • 코드 스타일 가이드 준수
  • 테스트 코드 포함됨
  • Reviewers / Assignees / Labels 지정 완료
  • 보안 및 민감 정보 검증 (API 키, 환경 변수, 개인정보 등)

@Soundbar91 Soundbar91 self-assigned this Sep 30, 2025
@Soundbar91 Soundbar91 added the 공통 백엔드 공통으로 작업할 이슈입니다. label Sep 30, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 30, 2025

Unit Test Results

668 tests   667 ✔️  1m 16s ⏱️
164 suites      1 💤
164 files        0

Results for commit fbce925.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Contributor

@dh2906 dh2906 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!
오... 확실히 로그 파일을 s3에 적재해둔다면 디스크 용량 부담도 줄고 파일 유실의 위험도 줄 것 같아요!

Copy link
Copy Markdown
Member

@kih1015 kih1015 left a comment

Choose a reason for hiding this comment

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

좋네요👍

군복무할때도 한달 단위로 데이터 압축해서 덤프 떠놨었는데 비슷한방식같네요

Copy link
Copy Markdown
Collaborator

@BaeJinho4028 BaeJinho4028 left a comment

Choose a reason for hiding this comment

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

운영 서버에서는 WARN 이상, 스테이지 환경에서는 INFO 이상으로 yml에 적용해주면 좋을 것 같네요.
고생하셨습니다 👍

@Soundbar91 Soundbar91 merged commit 285c169 into develop Oct 1, 2025
5 checks passed
@Soundbar91 Soundbar91 deleted the feat/2019-logback-file-rolling branch October 1, 2025 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

공통 백엔드 공통으로 작업할 이슈입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[공통] logback 롤링을 도입한다.

4 participants