mod_log_config.c
file, and is not
compiled in by default. It provides for logging of the requests made to
the server, using a user-specified format.
The argument to the LogFormat is a string, which can include literal characters copied into the log files, and `%' directives as follows:
%...h: Remote host %...l: Remote logname (from identd, if supplied) %...u: Remote user (from auth; may be bogus if return status (%s) is 401) %...t: Time, in common log format time format %...r: First line of request %...s: Status. For requests that got internally redirected, this is status of the original request --- %...>s for the last. %...b: Bytes sent. %...{Foobar}i: The contents of Foobar: header line(s) in the request sent to the client. %...{Foobar}o: The contents of Foobar: header line(s) in the reply.The `...' 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). Note that
there is no escaping performed on the strings from %r, %...i and
%...o; some with long memories may remember that I thought this was
a bad idea, once upon a time, and I'm still not comfortable with
it, but it is difficult to see how to `do the right thing' with all
of `%..i', unless we URL-escape everything and break with CLF.
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 default LogFormat reproduces CLF; see below.
The way this is supposed to work with virtual hosts is as follows: a virtual host can have its own LogFormat, or its own TransferLog. If it doesn't have its own LogFormat, it inherits from the main server. If it doesn't have its own TransferLog, it writes to the same descriptor (meaning the same process for `| ...').
That means that you can do things like:
<VirtualHost hosta.com>
LogFormat "hosta ..."
...
</VirtualHost>
<VirtualHost hosta.com>
LogFormat "hostb ..."
...
</VirtualHost>
... to have different virtual servers write into the same log file,
but have some indication which host they came from, though a %v
directive may well be a better way to handle this. Look for more
changes to come to this format.
LogFormat "%h %l %u %t \"%r\"
%s %b"
This sets the format of the logfile.
TransferLog logs/transfer_log
The TransferLog directive sets the name of the file to which the server will log the incoming requests. File-pipe is one of