This topic provides information about log formats and log files.
Use the following information to understand log formats. For information on how to configure logs, see Set up logs on HTTP Server (powered by Apache).
Log files contain one line for each request. A line is composed of several tokens separated by spaces. If a token does not have a value then it is represented by a hyphen (-). A line in a log file might look like the following:
192.168.1.3 - - [18/Feb/2000:13:33:37 -0600] "GET / HTTP/1.0" 200 5073
The following log file types are supported:
The common log format is defined by the following string:
"%h %l %u %t \"%r\" %>s %b"
NCSA's extended format is defined by the following string:
"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"\%{User-agent}i\"
Token | Description |
---|---|
%...a |
The remote client IP address. Example: 192.168.1.3 |
%...A |
The local client IP address. Example: 192.168.1.3 |
%...b |
The number of bytes transmitted, excluding HTTP headers in common log format. Example: - = no bytes transmitted |
%...B |
The number of bytes transmitted, excluding HTTP headers in extended log format. Example: 0 = no bytes transmitted |
%...{var}e |
The contents of the environment variable named var. |
%...f |
The requested file name. Example: /www/index.htm |
%...h |
The remote host name or IP address. Example: hal.ibm.com or 192.168.1.3 |
%...H |
The requested protocol. |
%...{var}i |
The contents of the HTTP header line named var. Example: %{User-agent}i = Mozilla/4.5 [en] (WinNT; U) |
%...l |
The remote logname. |
%...m |
The request method. |
%...{var}n |
The contents of the note named var. |
%...{var}o |
The contents of the header lines named var in the reply. |
%...p |
The canonical Port of the server serving the request. Example: 80 |
%...P |
The process ID that serviced the request. Example: 837 |
%...q |
The query string (or search argument) prepended with a "?". Example: ?name=hal |
%...r |
The first line of the request. Example: GET / HTTP/1.0 |
%...s |
The server response status. Example: 200 |
%...t |
The time in common log format. Example: [21/Mar/2000:14:08:03 -0600] |
%...{strftime}t |
The time in strftime format. |
%...T |
The time (in seconds) taken to serve the request. Example: 1 |
%...u |
The name of the authenticated remote user. Example: hal |
%...U |
The requested URL path. Example: / |
%...v |
The canonical server name of the server serving the request. |
%...V |
The server name according to the UseCanonicalName setting. |
Condition | Description |
---|---|
%>s |
Logs the returned status. |
%{User-agent}i |
Logs User-agent on all requests. |
%400,501{User-agent}i |
Logs User-agent only when a 400 error (Bad Request) or a 501 error (Not Implemented) is encountered. |
%!200,304,302{Referer}i |
Logs Referer on all requests which did not return some sort of normal status. |