본문 바로가기

ETC/TIP

Apache Tomcat access log 설정

Tomcat은 기본적으로 access log를 저장한다. /conf/server.xml에서 변경이 가능하다.


<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="false">

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt"

               pattern="combined" />

</Host>


아래 패턴을 통해 조합이 가능하다.


%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)



%{xxx}i for incoming headers

%{xxx}o for outgoing response headers

%{xxx}c for a specific cookie

%{xxx}r xxx is an attribute in the ServletRequest

%{xxx}s xxx is an attribute in the HttpSession

%{xxx}t xxx is an enhanced SimpleDateFormat pattern (see Configuration Reference document for details on supported time patterns)


아래 설명 처럼 aliases로 사용되는 패턴도 있다.


In addition, the caller can specify one of the following aliases for commonly utilized patterns:


common - %h %l %u %t "%r" %s %b

combined - %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"