Skip to content

예외 로깅 레벨 4xx/5xx 분리#246

Open
ckdals4600 wants to merge 1 commit into
mainfrom
feature/#243-separate-exception
Open

예외 로깅 레벨 4xx/5xx 분리#246
ckdals4600 wants to merge 1 commit into
mainfrom
feature/#243-separate-exception

Conversation

@ckdals4600

@ckdals4600 ckdals4600 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

관련 이슈

PR 설명

배경

  • 모든 핸들러가 log.error(ex.getMessage(), ex)로 동일하게 로깅하여,
    클라이언트 잘못인 4xx(검증 실패, 405, 404 등)까지 ERROR + 풀스택으로 기록됨.
  • 운영 로그에서 Request method 'POST' is not supported, 채팅을 찾을 수 없습니다 등이 ERROR 로 다수 확인됨.
  • 이 상태로 ERROR 알림을 도입하면 클라이언트 실수 때문에 계속 울려 알림이 무의미해짐.

적용된 로깅 원칙

  • 4xx (클라이언트 잘못): WARN, 스택 트레이스 없이 메시지만. 서버 문제가 아니므로 ERROR 금지.
  • 5xx (서버 잘못): ERROR, 예외 객체를 넘겨 전체 스택 트레이스를 남김.
  • 봇 스캔성 404 등 고빈도 노이즈: DEBUG.
  • 민감 데이터가 들어가는 예외라면 메시지를 그대로 찍지 말고 필요한 필드만 추려 남길 것.

변경 사항

  • 검증/바인딩/HTTP 메서드 예외(확정 4xx) → WARN, 스택 트레이스 없이 핵심 필드만 기록
  • BusinessExceptionErrorCode.getStatus()로 분기: 5xx만 ERROR + 스택, 4xx는 WARN
  • catch-all Exception(예상 못 한 5xx) → ERROR + 풀스택 유지, 예외 객체를 인자로 전달
  • 메시지에 요청 본문/PII가 섞일 수 있는 예외는 고정 문구만 기록

@ckdals4600 ckdals4600 self-assigned this Jun 21, 2026
@ckdals4600 ckdals4600 requested review from Goder-0 and minibr June 21, 2026 07:53
@github-actions

Copy link
Copy Markdown

📊 코드 커버리지 리포트

Overall Project 94.2% -0.68% 🍏
Files changed 39.66% 🍏

File Coverage
GlobalExceptionHandler.java 36.36% -31.82% 🍏

Comment on lines 26 to 33
@ExceptionHandler(NoResourceFoundException.class)
public ResponseEntity<Void> handleNoResourceFound(NoResourceFoundException exception) {
if (exception.getResourcePath().contains("favicon")) {
return ResponseEntity.notFound().build();
}
log.error("No static resource {}", exception.getResourcePath(), exception);
return ResponseEntity.notFound().build();
}

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.

4xx/5xx 분리 정책이라면 NoResourceFoundException 도 같이 내려가는 게 맞아 보입니다. 지금은 정적 리소스 404 가 아직 ERROR + stack trace 로 남아서 운영 노이즈가 계속 생길 수 있습니다.`

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.

예외 레벨 정책 정립: 예상 가능한 4xx 와 실제 5xx 분리

2 participants