csct3434
스프링부트 액세스 로그 설정 방법 본문
application.properties
server:
tomcat:
basedir: /app
accesslog:
enabled: true
directory: logs
prefix: access_log
suffix: .log
rotate: true
max-days: 2
pattern: "%h %l %u %t \"%r\" %s %b"
- 로그 저장 위치 : ${basedir}/${directory}/${prefix}.{yyyy-MM-dd}${suffix}
- 예시 : /app/logs/access_log.2024-05-25.log
- rotate : 로그 로테이션 활성화 (기본값 : true)
- max-days : 로그 로테이션 시 저장 기간 (기본값 : -1, 영구 보관)
- pattern : 로그 포맷 (기본값 : common, "%h %l %u %t \"%r\" %s %b")
액세스 로그 예시
10.0.2.6 - - [25/May/2024:19:24:57 +0900] "GET /notification HTTP/1.1" 401 13 87
- pattern : "%h %l %u %t \"%r\" %s %b %F"
- %h : 원격 IP 주소 (10.0.2.6)
- %r : HTTP 요청 첫번째 라인 - Method, URL + Query String, Version (GET /notification HTTP 1.1)
- %s : 응답 상태코드
- %b : Response body 크기 (13) (byte)
- %F : HTTP Response의 첫번째 바이트를 전송하기까지 소요된 시간 (87) (ms)
- %D : 요청을 처리하기까지 소요된 전체 시간 (응답 전송 시간 포함)
- 즉, %D는 Response Body의 크기와 네트워크 전송 속도에 영향을 받음
- 서버측의 로직 처리 시간을 모니터링할 경우 %F가 %D보다 정확함
관련 문서
https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html
Apache Tomcat 8 Configuration Reference (8.0.53) - The Valve Component
The Access Log Valve creates log files in the same format as those created by standard web servers. These logs can later be analyzed by standard log analysis tools to track page hit counts, user session activity, and so on. This Valve uses self-contained l
tomcat.apache.org
'개발' 카테고리의 다른 글
AWS WAF를 활용한 웹 스캐닝 공격 차단 (feat. web ACL) (1) | 2024.06.04 |
---|---|
CloudWatch Log Group으로 로그 전송하기 (feat. CloudWatch Agent) (0) | 2024.05.25 |
Amazon S3 트리거와 Lambda를 활용한 썸네일 이미지 생성 (2) - 코드 구현 (1) | 2024.04.20 |
Amazon S3 트리거와 Lambda를 활용한 썸네일 이미지 생성 (1) - 인프라 구축 (1) | 2024.04.16 |
중앙 집중식 로깅 구현하기 (feat. Logback, CloudWatch Logs) (0) | 2024.03.30 |