From: Joshua Slive (This directive was (This directive was
- %%The percent sign
+ %...a
- %aRemote IP-address
+ %...A
- %ALocal IP-address
+ %...B
- %BSize of response in bytes, excluding HTTP headers.
+ %...b
- %bSize of response in bytes, excluding HTTP headers. In CLF format, i.e.
a ' -' rather than a 0 when no bytes are sent.
+ %...{Foobar}C
- %{Foobar}CThe contents of cookie Foobar in the request sent
to the server.
+ %...D
- %DThe time taken to serve the request, in microseconds.
+ %...{FOOBAR}e
- %{FOOBAR}eThe contents of the environment variable
FOOBAR
+ %...f
- %fFilename
+ %...h
- %hRemote host
+ %...H
- %HThe request protocol
+ %...{Foobar}i
- %{Foobar}iThe contents of Foobar: header line(s)
in the request sent to the server.
+ %...l
- %lRemote logname (from identd, if supplied). This will return a
dash unless On.
+ %...m
- %mThe request method
+ %...{Foobar}n
- %{Foobar}nThe contents of note Foobar from another
module.
+ %...{Foobar}o
- %{Foobar}oThe contents of Foobar: header line(s)
in the reply.
+ %...p
- %pThe canonical port of the server serving the request
+ %...P
- %PThe process ID of the child that serviced the request.
+ %...{format}P
- %{format}PThe process ID or thread id of the child that serviced the
request. Valid formats are pid and tid.
+ %...q
- %qThe query string (prepended with a ? if a query
string exists, otherwise an empty string)
+ %...r
- %rFirst line of request
+ %...s
- %sStatus. For requests that got internally redirected, this is
- the status of the *original* request --- %...>s
+ the status of the *original* request --- %>s
for the last.
+ %...t
- %tTime the request was received (standard english
format)
+ %...{format}t
- %{format}tThe time, in the form given by format, which should be in
strftime(3) format. (potentially localized)
+ %...T
- %TThe time taken to serve the request, in seconds.
+ %...u
- %uRemote user (from auth; may be bogus if return status
( %s) is 401)
+ %...U
- %UThe URL path requested, not including any query string.
+ %...v
- %vThe canonical
+ %...V
- %VThe server name according to the
+ %...X
+ %XConnection status when response is completed:
@@ -188,92 +188,92 @@
sent.
- %...c in late versions of Apache
+ %c in late versions of Apache
1.3, but this conflicted with the historical ssl
- %...{var}c syntax.)%{var}c syntax.)
%...I%I%...O%OThe "..." can be nothing at all (e.g.,
- "%h %u %r %s %b"), or it can indicate conditions for
- inclusion of the item (which will cause it to be replaced with "-" if
- the condition is not met). The forms of condition are a list of
- HTTP status codes, which may or may not be preceded by "!".
- Thus, "%400,501{User-agent}i" logs User-agent: on 400
- errors and 501 errors (Bad Request, Not Implemented) only;
- "%!200,304,302{Referer}i" logs Referer: on all requests
- which did not return some sort of normal status.
The modifiers "<" and ">" can be used for requests that
- have been internally redirected to choose whether the original or
- final (respectively) request should be consulted. By default, the
- % directives %s, %U, %T, %D, and
- %r look at the original request while all others look
- at the final request. So for example, %>s can be
- used to record the final status of the request and
- %<u can be used to record the original
- authenticated user on a request that is internally redirected to an
- unauthenticated resource.
Note that in httpd 2.0 versions prior to 2.0.46, no escaping was performed
- on the strings from %...r, %...i and
- %...o. This was mainly to comply with the requirements of
- the Common Log Format. This implied that clients could insert control
- characters into the log, so you had to be quite careful when dealing
- with raw log files.
For security reasons, starting with 2.0.46, non-printable and
- other special characters are escaped mostly by using
- \xhh sequences, where hh stands for
- the hexadecimal representation of the raw byte. Exceptions from this
- rule are " and \ which are escaped by prepending
- a backslash, and all whitespace characters which are written in their
- C-style notation (\n, \t etc).
Note that in httpd 2.0, unlike 1.3, the %b and
- %B format strings do not represent the number of
- bytes sent to the client, but simply the size in bytes of the HTTP
- response (which will differ, for instance, if the connection is
- aborted, or if SSL is used). The %O format provided
- by
Some commonly used log format strings are:
- -"%h %l %u %t \"%r\" %>s %b""%v %h %l %u %t \"%r\" %>s %b""%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
- \"%{User-agent}i\"""%{Referer}i -> %U""%{User-agent}i"Note that the canonical %v and %p
- respectively. This happens regardless of the
Particular items can be restricted to print only for
+ responses with specific HTTP status codes by placing a
+ comma-separated list of status codes immediately following the
+ "%". For example, "%400,501{User-agent}i" logs
+ User-agent on 400 errors and 501 errors only. For
+ other status codes, the literal string "-" will be
+ logged. The status code list may be preceded by a
+ "!" to indicate negation:
+ "%!200,304,302{Referer}i" logs Referer
+ on all requests that do not return one of the three
+ specified codes.
The modifiers "<" and ">" can be used for requests that
+ have been internally redirected to choose whether the original
+ or final (respectively) request should be consulted. By
+ default, the % directives %s, %U, %T,
+ %D, and %r look at the original request
+ while all others look at the final request. So for example,
+ %>s can be used to record the final status of
+ the request and %<u can be used to record the
+ original authenticated user on a request that is internally
+ redirected to an unauthenticated resource.
For security reasons, starting with version 2.0.46,
+ non-printable and other special characters in %r,
+ %i and %o are escaped using
+ \xhh sequences, where hh
+ stands for the hexadecimal representation of the raw
+ byte. Exceptions from this rule are " and
+ \, which are escaped by prepending a backslash, and
+ all whitespace characters, which are written in their C-style
+ notation (\n, \t, etc). In versions
+ prior to 2.0.46, no escaping was performed on these strings so
+ you had to be quite careful when dealing with raw log files.
In httpd 2.0, unlike 1.3, the %b and
+ %B format strings do not represent the number of
+ bytes sent to the client, but simply the size in bytes of the
+ HTTP response (which will differ, for instance, if the
+ connection is aborted, or if SSL is used). The %O
+ format provided by
Some commonly used log format strings are:
+ +"%h %l %u %t \"%r\" %>s %b""%v %h %l %u %t \"%r\" %>s %b""%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
+ \"%{User-agent}i\"""%{Referer}i -> %U""%{User-agent}i"