Skip to content

[chore] PB-116 로깅 표준 적용 - #227

Merged
PHJ2000 merged 9 commits into
mainfrom
chore/PB-116-logging-standard
Jun 8, 2026
Merged

PHJ2000 merged 9 commits into
mainfrom
chore/PB-116-logging-standard

Conversation

@geonusp

@geonusp geonusp commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

🧰 Chore PR

🔗 Jira Issue (필수)

PR 제목: [chore] PB-116 로깅 표준 적용
브랜치: chore/PB-116-logging-standard


🔒 Close Issue (필수)


🧩 한눈에 요약 (필수)

무엇을 변경했나?

  • 인프라
  • 설정파일 (logback-spring.xml, application-{dev,prod}.yml)
  • 빌드 파일 (build.gradle 의존성)
  • CI
  • 의존성
  • 런타임 코드 변경 있음 — MDC 주입 필터 신규, 인증 필터 수정,
    인증 DTO toString PII 마스킹 (ADR-0XX)

왜 필요한가?

  • 외부 로깅 저장소 도입을 위해 prod 프로파일 로그를 NDJSON으로 직렬화하고,
    요청/사용자 단위 추적이 가능하도록 MDC(requestId·userId) 표준을 적용 (ADR-0XX)
  • 인증 DTO의 record 기본 toString이 password·token·email 평문을 로그에
    노출하던 문제를 toString 오버라이드로 차단 (PII 마스킹)

범위(스코프)

  • Included: logback-spring.xml 프로파일별 로깅 정책, dev/prod yml 골격,
    MdcRequestFilter 신규, JwtAuthenticationFilter userId MDC 주입,
    인증 DTO 6종 toString 마스킹, logstash-logback-encoder 의존성
  • Not included: 외부 호출 헤더 전파, traceId/spanId 자동 주입(ADR-0XX 트레이싱 SDK 예정)

🧪 테스트 / 검증 (필수)

로컬

  • Command: ./gradlew test --tests "com.beachcheck.global.logging.*" \ --tests "com.beachcheck.global.security.JwtAuthenticationFilterTest" \ --tests "com.beachcheck.auth.dto.DtoToStringMaskingTest"
  • Result: <성공/실패 + 통과 개수 기재>

테스트 공백

  • 없음 — 신규 필터·DTO 마스킹 단위 테스트 470줄 추가 (정상/예외/MDC 누수 케이스 포함)

🧭 영향 범위 (필수)

  • 설정/환경변수 변경 있음 (항목: SPRING_PROFILES_ACTIVE — dev/prod 프로파일 분기,
    미지정 시 default 프로파일로 평문 로깅)
  • CI/빌드 파이프라인 영향 없음
  • 의존성 변경 있음 (net.logstash.logback:logstash-logback-encoder:7.4 신규 추가)

⚠️ 리스크 & 롤백 (필수)

리스크

  • prod 배포 시 SPRING_PROFILES_ACTIVE=prod 미주입 시 default 프로파일로 떨어져
    평문 로그가 출력될 수 있음 (CD 환경변수 확인 필요)
  • 기존 application.yml의 logging.level 블록 제거 → 로깅 정책이 logback-spring.xml로
    완전 이관됨. prod에서 com.beachcheck=INFO, Hibernate SQL/bind=OFF로 레벨 변동

롤백

  • 단순 revert로 가능

💬 리뷰 가이드 (필수)

  • 꼭 봐야 하는 파일: logback-spring.xml(프로파일별 정책),
    JwtAuthenticationFilter(try-finally MDC 정리), AuthResponseDto/UserResponseDto(부분 마스킹)
  • 트레이드오프: Response DTO는 전체 마스킹 대신 id/role/expiresIn 등 비민감 필드는
    디버깅 편의를 위해 노출 유지
  • 보안 영향: 인증 DTO toString의 평문 PII 노출 차단이 본 PR의 핵심 보안 변경

geonusp added 2 commits May 20, 2026 02:51
  - logstash-logback-encoder 7.4 의존성 추가
  - logback-spring.xml 신규 — dev 평문 / prod NDJSON 프로파일 분기
  - MdcRequestFilter 신규 — requestId MDC 주입 + X-Request-Id 응답 헤더
  - JwtAuthenticationFilter — 인증 성공 시 userId MDC 주입, finally 정리
  - application.yml — logging.level 블록 제거 (logback-spring.xml로 일원화)
  - application-dev.yml / application-prod.yml — 프로파일 활성화 골격
record 기본 toString이 평문 password/token/email을 노출하는 것을 차단.

   - Request 3개 (LogIn/SignUp/RefreshToken): 전체 마스킹
   - Response 3개 (Token/Auth/UserResponse): 토큰·email·name만 마스킹,
     tokenType/expiresIn/id/role 등 디버그용 메타데이터는 유지
   - AuthResponseDto.user 필드 체이닝으로 인한
     UserResponseDto 노출도 함께 차단
   - Response 3개 (Token/Auth/UserResponse): 토큰·email·name만 마스킹,
     tokenType/expiresIn/id/role 등 디버그용 메타데이터는 유지
   - AuthResponseDto.user 필드 체이닝으로 인한
     UserResponseDto 노출도 함께 차단
@geonusp
geonusp requested a review from PHJ2000 May 19, 2026 18:09
@geonusp geonusp self-assigned this May 19, 2026
@geonusp geonusp added the chore label May 19, 2026
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6e1fb040-ac34-4a75-9a1c-cc45e0537e2e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/PB-116-logging-standard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@geonusp geonusp changed the title Chore/pb 116 logging standard [chore] PB-116 로깅 표준 적용 May 19, 2026
@geonusp
geonusp marked this pull request as draft May 21, 2026 04:43
geonusp added 2 commits May 22, 2026 02:57
  - MdcRequestFilterTest: requestId 주입·헤더 전파·MDC 누수 방지
   - JwtAuthenticationFilterTest: userId MDC 주입/정리, userIdPushed 가드
   - DtoToStringMaskingTest: 6개 record DTO toString에 평문 PII 미노출
@geonusp
geonusp marked this pull request as ready for review May 22, 2026 16:52

@PHJ2000 PHJ2000 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

리뷰 코멘트 남깁니다.

Comment thread src/main/resources/logback-spring.xml Resolved
Comment thread src/main/resources/logback-spring.xml Resolved
geonusp added 3 commits June 8, 2026 19:01
- MaskingUtils 신규 추가로 전체/부분 마스킹 표현을 공통화

- 인증 request DTO의 직접 문자열 마스킹을 maskedRecord 호출로 통일

- 인증 response DTO의 민감 필드 마스킹 표현을 maskedField 호출로 통일

- ResendVerificationRequestDto 누락 마스킹 추가

- DTO toString 마스킹 테스트에 재전송 요청 케이스 추가
- logback-spring.xml 평문 appender 프로파일 범위에 test 추가

- CI의 SPRING_PROFILES_ACTIVE=test 실행 시 콘솔 appender가 적용되도록 보정

- dev/local/test/default 평문 로그 패턴에 requestId MDC 출력 추가

- traceId/requestId/userId 키 이름을 명시해 로컬 요청 추적 가독성 개선
- logback-spring.xml을 dev/prod 프로파일로 초기화해 DTO 로그 샘플 생성

- 인증 request/response DTO와 주요 일반 DTO의 로그 출력 형태를 한 파일에서 비교

- MDC traceId/spanId/userId/requestId가 dev 평문과 prod JSONL에 반영되는지 검증

- 샘플 로그를 build/reports/logging-smoke 경로에 dev.log/prod.jsonl 형태로 저장

- 이메일·비밀번호·토큰 샘플 값이 로그 출력에 남지 않는지 방어 검증
@geonusp

geonusp commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator Author

요새 코드리뷰없이 코딩했어서 실력이 많이 떨어진게 느껴지네요 ㅠ 코드리뷰반영했습니다. 확인부탁드립니다!

geonusp added 2 commits June 8, 2026 20:31
- Checkstyle FinalClass 규칙에 맞춰 테스트 내부 UserBuilder를 final 클래스로 변경

- Checkstyle FinalClass 규칙에 맞춰 테스트 내부 RefreshTokenBuilder를 final 클래스로 변경

- 빌드 단계의 checkstyleTest 실패 원인을 테스트 헬퍼 선언 범위에서 최소 수정
- dev 평문 로그 패턴이 traceId/requestId/userId 키 이름을 출력하도록 변경된 상태를 반영

- 기존 압축 형태 [trace,user] 기대값을 명시적 MDC 키 검증으로 교체

- requestId 출력 추가 후 DtoLoggingCatalogTest dev 프로파일 assertion 실패를 수정
@PHJ2000

PHJ2000 commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

수고하셨습니다!

@PHJ2000
PHJ2000 merged commit 5b36540 into main Jun 8, 2026
2 checks passed
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.

[chore] PB-116 로깅 표준 적용

2 participants