Skip to content

API 요청/응답 로깅 개선#245

Open
ckdals4600 wants to merge 3 commits into
mainfrom
feature/edit-RequestLoggingFilter
Open

API 요청/응답 로깅 개선#245
ckdals4600 wants to merge 3 commits into
mainfrom
feature/edit-RequestLoggingFilter

Conversation

@ckdals4600

@ckdals4600 ckdals4600 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

관련 이슈

PR 설명

배경

  • 기존 RequestLoggingFilter가 모든 요청의 헤더·바디를 INFO 로 통째 로깅하여
    authorization/cookie의 JWT 토큰, 로그인 요청의 비밀번호가 평문으로 남고 있었음.
  • 헬스체크·정적리소스·스캐너 탐색 요청까지 매번 기록되어 운영 로그가 노이즈로 가득 찼음.

변경 사항

민감 정보 로깅 제거

  • INFO 로그에서 헤더/바디 전체 덤프 제거 → method / uri / status / 소요시간 / ip / user-agent만 한 줄로 기록
  • 요청 헤더는 DEBUG 에서만 출력하며 민감 헤더(Authorization, Cookie, Set-Cookie 등)는 값 전체 마스킹
  • 응답 헤더(Set-Cookie)는 로깅하지 않아 토큰이 헤더로 새지 않음

요청/응답 본문 로깅 (마스킹 적용)

  • 응답 본문: INFO 기록, 민감 필드(email 등)·JWT 패턴 마스킹 + 2000자 상한
  • 요청 본문: DEBUG 기록(클라이언트 통제 불가 입력이라 보수적), 동일 마스킹 적용
  • email/password/토큰류 필드 값 마스킹, 필드명과 무관하게 eyJ... JWT 패턴은 통째로 마스킹
  • ContentCachingResponseWrapper 사용 시 copyBodyToResponse() 호출로 빈 응답 방지
  • 파일 업로드(multipart)·바이너리는 메모리 버퍼링 방지를 위해 래핑·로깅에서 제외

로그 노이즈 제거

  • RequestLoggingFilter에서 노이즈 경로(/actuator, /favicon.ico, /swagger, /v3/api-docs) 요청 로깅 제외
  • GlobalExceptionHandler에서 NoResourceFoundException(스캐너 404) ERROR → DEBUG 강등
  • JwtTokenProvider에서 익명 요청에 대한 Token not found 로그 삭제

@ckdals4600 ckdals4600 requested review from Goder-0 and minibr June 18, 2026 13:11
@ckdals4600 ckdals4600 self-assigned this Jun 18, 2026
@ckdals4600 ckdals4600 changed the title Feature/edit request logging filter API 요청/응답 로깅 개선 (민감정보 마스킹 · 노이즈 제거) Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

📊 코드 커버리지 리포트

Overall Project 93.29% -1.69% 🍏
Files changed 80.67% 🍏

File Coverage
JwtTokenProvider.java 92.22% 🍏
RequestLoggingFilter.java 81.8% -18.2% 🍏
GlobalExceptionHandler.java 36.36% -5.68%

@ckdals4600 ckdals4600 changed the title API 요청/응답 로깅 개선 (민감정보 마스킹 · 노이즈 제거) API 요청/응답 로깅 개선 Jun 18, 2026
Comment thread src/main/java/com/sofa/linkiving/global/fillter/RequestLoggingFilter.java Outdated
@ckdals4600 ckdals4600 force-pushed the feature/edit-RequestLoggingFilter branch 2 times, most recently from 4c061c2 to fc597ae Compare June 21, 2026 07:47
@ckdals4600

Copy link
Copy Markdown
Contributor Author

@Goder-0
JwtTokenProvider 수정 사항 추가 됐습니다. 확인 부탁드립니다.

Comment thread src/main/java/com/sofa/linkiving/global/fillter/RequestLoggingFilter.java Outdated
@ckdals4600 ckdals4600 force-pushed the feature/edit-RequestLoggingFilter branch from fc597ae to 7b7fb0d Compare June 24, 2026 12:45

@Goder-0 Goder-0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR 설명에는 “응답 본문: INFO 기록”이라고 적혀 있는데, 현재 구현은 요청/응답 본문 모두 DEBUG에서만 남기고 있습니다. 구현 의도가 맞다면 PR 설명을 수정해두는 게 좋겠습니다.

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.

응답 본문 로깅 추가 (DEBUG 레벨) 운영 로그에서 스캐너·정적리소스 요청 제외 요청 로깅 방식 수정

2 participants