mod_log_config.html revision 12964a252085bbd5e5be68438e3bb910632f3981
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>Apache module mod_log_config</TITLE>
</HEAD>
<BODY>
<!--#include virtual="header.html" -->
<H1>Module mod_log_config</h1>
and is compiled in by default in Apache 1.2. mod_log_config replaces
mod_log_common in Apache 1.2. Prior to version 1.2, mod_log_config was
an optional module. It provides for logging of the requests made to
the server, using a user-specified format.
<h2>Summary</h2>
The argument to the <A HREF="#logformat">LogFormat</A> is a string, which can
include literal characters copied into the log files, and `%' directives as
follows:
<PRE>
%...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 <b>original</b> 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.
</PRE>
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.
<P>
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 <b>not</b> return some sort of normal status.
<P>
The default LogFormat reproduces CLF; see below.
<P>
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 `| ...').
<P>
That means that you can do things like:
<blockquote><code>
<VirtualHost hosta.com><br>
LogFormat "hosta ..."<br>
...<br>
</VirtualHost><br>
<br>
<VirtualHost hosta.com><br>
LogFormat "hostb ..."<br>
...<br>
</VirtualHost></code></blockquote>
... 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.<p>
<h2>Directives</h2>
<ul>
<li><A HREF="#logformat">LogFormat</A>
<li><A HREF="#transferlog">TransferLog</A>
<LI><A HREF="#customlog">CustomLog</A>
</ul>
<hr>
<A name="logformat"><h2>LogFormat</h2></A>
<!--%plaintext <?INDEX {\tt LogFormat} directive> -->
<strong>Syntax:</strong> LogFormat <em>string</em><br>
<strong>Default:</strong> <code>LogFormat "%h %l %u %t \"%r\"
%s %b"</code><br>
<Strong>Context:</strong> server config, virtual host<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_log_config<p>
This sets the format of the logfile.<p><hr>
<A name="transferlog"><h2>TransferLog</h2></A>
<!--%plaintext <?INDEX {\tt TransferLog} directive> -->
<strong>Syntax:</strong> TransferLog <em>file-pipe</em><br>
<Strong>Context:</strong> server config, virtual host<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_log_config<p>
The TransferLog directive sets the name of the file to which the server will
log the incoming requests. <em>File-pipe</em> is one
of
<dl><dt>A filename
<dt> `|' followed by a command
<dd>A program to receive the agent log information on its standard input.
Note the a new program will not be started for a VirtualHost if it inherits
the TransferLog from the main server.
</dl>
<strong>Security:</strong> if a program is used, then it will be
run under the user who started httpd. This will be root if the server
was started by root; be sure that the program is secure.<p>
<A NAME="customlog"><H2>CustomLog</H2></A>
<STRONG>Syntax:</STRONG> CustomLog <em>file-pipe</em> <em>format</em><BR>
<STRONG>Context:</STRONG> server config, virtual host<BR>
<STRONG>Status:</STRONG> Base<BR>
<STRONG>Module:</STRONG> mod_log_config<P>
CustomLog combines TransferLog and LogFormat -- the format specified
to this directive is logged to the file or pipe specified.<P>
<!--#include virtual="footer.html" -->
</BODY>
</HTML>