Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

csct3434

스프링부트 액세스 로그 설정 방법 본문

개발 일지

스프링부트 액세스 로그 설정 방법

csct3434 2024. 5. 25. 19:36

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