1. tomcat/conf/server.xml 에 access log 생성 관련 추가
<Server port="8015" shutdown="SHUTDOWN">
<Service name="Catalina">
...
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
...
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b %D" />
</Host>
</Service>
</Server>
- 위 내용처럼 <Host> 태그 및 에 <Value> 태그를 생성
- prefix , suffix 설정하면 /logs 폴더 및에 파일 생성
- pattern은 아래 내용 확인 ( 자세히 : https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/valves/AccessLogValve.html )
%a - Remote IP address
%A - Local IP address
%b - Bytes sent, excluding HTTP headers, or '-' if no bytes were sent
%B - Bytes sent, excluding HTTP headers
%h - Remote host name (or IP address if enableLookups for the connector is false)
%H - Request protocol
%l - Remote logical username from identd (always returns '-')
%m - Request method
%p - Local port
%q - Query string (prepended with a '?' if it exists, otherwise an empty string
%r - First line of the request
%s - HTTP status code of the response
%S - User session ID
%t - Date and time, in Common Log Format format
%u - Remote user that was authenticated
%U - Requested URL path
%v - Local server name
%D - Time taken to process the request, in millis
%T - Time taken to process the request, in seconds
%I - current Request thread name (can compare later with stacktraces)
결과:
// pattern="%h %l %u %t "%r" %s %b %D"
127.0.0.1 - - [04/Sep/2023:00:00:13 +0900] "GET /sse HTTP/1.1" 200 43 11
(%h) (%l) (%u) (%t) (%r) (%s) (%b) (%D)
- 중요부분만 보면 /sse 라는 GET 방식 API 요청 결과 , 성공(200) 했고 ,헤더 포함 43byte 전송.
- 요청 소요 시간은 11 (millesec) .
'server > tomcat' 카테고리의 다른 글
Tomcat SSL 인증서 적용 (0) | 2023.02.20 |
---|