mod_log_config.html revision 3d76f0e292da6a107829fbe83f98b8c0985c6ddb
6384N/A<!--%hypertext -->
6384N/A<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
6384N/A<HTML>
6384N/A<HEAD>
6384N/A<TITLE>Apache module mod_log_config</TITLE>
6384N/A</HEAD>
6384N/A
6384N/A<BODY>
6384N/A<IMG SRC="/images/apache_sub.gif" ALT="">
6384N/A<!--/%hypertext -->
6384N/A<H1>Module mod_log_config</h1>
6384N/A
6384N/AThis module is contained in the <code>mod_log_config.c</code> file, and is not
6384N/Acompiled in by default. It provides for logging of the requests made to
6384N/Athe server, using a user-specified format.
6384N/A
6384N/A<h2>Summary</h2>
6384N/AThis is an EXPERIMENTAL module, which implements the TransferLog directive
6384N/A(same as the common log module), and an additional directive, LogFormat.
6384N/ABugs would not surprise me.<P>
6384N/A
6384N/AThe argument to the <A HREF="#logformat">LogFormat</A> is a string, which can
6384N/Ainclude literal characters copied into the log files, and `%' directives as
6384N/Afollows:
6384N/A
6384N/A<PRE>
6384N/A%...h: Remote host
6384N/A%...l: Remote logname (from identd, if supplied)
6384N/A%...u: Remote user (from auth; may be bogus if return
6384N/A status (%s) is 401)
6384N/A%...t: Time, in common log format time format
6384N/A%...r: First line of request
6384N/A%...s: Status. For requests that got internally redirected,
6384N/A this is status of the <b>original</b> request --- %...>s
6384N/A for the last.
6384N/A%...b: Bytes sent.
6384N/A%...{Foobar}i: The contents of Foobar: header line(s) in the request
6384N/A sent to the client.
6384N/A%...{Foobar}o: The contents of Foobar: header line(s) in the reply.
6384N/A</PRE>
6384N/A
6384N/AThe `...' can be nothing at all (e.g. <code>"%h %u %r %s %b"</code>), or it can
6384N/Aindicate conditions for inclusion of the item (which will cause it
6384N/Ato be replaced with `-' if the condition is not met). Note that
6384N/Athere is no escaping performed on the strings from %r, %...i and
6384N/A%...o; some with long memories may remember that I thought this was
6384N/Aa bad idea, once upon a time, and I'm still not comfortable with
6384N/Ait, but it is difficult to see how to `do the right thing' with all
6384N/Aof `%..i', unless we URL-escape everything and break with CLF.
6384N/A
6384N/A<P>
6384N/A
6384N/AThe forms of condition are a list of HTTP status codes, which may
6384N/Aor may not be preceded by `!'. Thus, `%400,501{User-agent}i' logs
6384N/AUser-agent: on 400 errors and 501 errors (Bad Request, Not
6384N/AImplemented) only; `%!200,304,302{Referer}i' logs Referer: on all
6384N/Arequests which did <b>not</b> return some sort of normal status.
6384N/A
6384N/A<P>
6384N/A
7151N/AThe default LogFormat reproduces CLF; see below.
7151N/A
7151N/A<P>
6384N/A
6384N/AThe way this is supposed to work with virtual hosts is as follows:
6384N/Aa virtual host can have its own LogFormat, or its own TransferLog.
6384N/AIf it doesn't have its own LogFormat, it inherits from the main
6384N/Aserver. If it doesn't have its own TransferLog, it writes to the
6384N/Asame descriptor (meaning the same process for `| ...').
6384N/A
6384N/A<P>
6384N/A
6384N/AThat means that you can do things like:
6384N/A
6384N/A<blockquote><code>
6384N/A&lt;VirtualHost hosta.com&gt;<br>
6384N/ALogFormat "hosta ..."<br>
6384N/A...<br>
&lt;/VirtualHost&gt;<br>
<br>
&lt;VirtualHost hosta.com&gt;<br>
LogFormat "hostb ..."<br>
...<br>
&lt;/VirtualHost&gt;</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>
<!--%hypertext -->
<h2>Directives</h2>
<ul>
<li><A HREF="#logformat">LogFormat</A>
<li><A HREF="#transferlog">TransferLog</A>
</ul>
<hr>
<!--/%hypertext -->
<A name="logformat"><h2>LogFormat</h2></A>
<!--%plaintext &lt;?INDEX {\tt LogFormat} directive&gt; -->
<strong>Syntax:</strong> LogFormat <em>string</em><br>
<strong>Default:</strong> <code>LogFormat &quot;%h %l %u %t \&quot;%r\&quot;
%s %b&quot;</code><br>
<Strong>Context:</strong> server config, virtual host<br>
<strong>Status:</strong> Experimental<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 &lt;?INDEX {\tt TransferLog} directive&gt; -->
<strong>Syntax:</strong> TransferLog <em>file-pipe</em><br>
<strong>Default:</strong> <code>TransferLog logs/transfer_log</code><br>
<Strong>Context:</strong> server config, virtual host<br>
<strong>Status:</strong> Experimental<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
<dd>A filename relative to the <A HREF="core.html#serverroot">ServerRoot</A>.
<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>
<!--%hypertext -->
<hr>
<A HREF="../"><IMG SRC="/images/apache_home.gif" ALT="Home"></A>
<A HREF="./"><IMG SRC="/images/apache_index.gif" ALT="Index"></A>
</BODY>
</HTML>
<!--/%hypertext -->