mod_log_config.html revision 56813ddcd91e3e845950c4aebdfb62e222965159
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor<html xmlns="http://www.w3.org/1999/xhtml">
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <head>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <meta name="generator" content="HTML Tidy, see www.w3.org" />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <title>Apache module mod_log_config</title>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor </head>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor vlink="#000080" alink="#FF0000">
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <!--#include virtual="header.html" -->
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <h1 align="CENTER">Module mod_log_config</h1>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>This module provides for logging of the requests made to the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor server, using the Common Log Format or a user-specified
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor format.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p><a href="module-dict.html#Status"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Status:</strong></a> Base<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="module-dict.html#SourceFile"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Source File:</strong></a>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor mod_log_config.c<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="module-dict.html#ModuleIdentifier"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Module Identifier:</strong></a>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor log_config_module</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <h2>Summary</h2>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>This module provides for flexible logging of client
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor requests. Logs are written in a customizable format, and may be
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor written directly to a file, or to an external program.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor Conditional logging is provided so that individual requests may
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor be included or excluded from the logs based on characteristics
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor of the request.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>Three directives are provided by this module:
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <code>TransferLog</code> to create a log file,
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <code>LogFormat</code> to set a custom format, and
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <code>CustomLog</code> to define a log file and format in one
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor step. The <code>TransferLog</code> and <code>CustomLog</code>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor directives can be used multiple times in each server to cause
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor each request to be logged to multiple files.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>See also: <a href="/logs.html">Apache Log Files</a>.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <h2>Directives</h2>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <ul>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <li><a href="#cookielog">CookieLog</a></li>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <li><a href="#customlog">CustomLog</a></li>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <li><a href="#logexcludebytype">LogExcludeByType</a></li>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <li><a href="#logformat">LogFormat</a></li>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <li><a href="#transferlog">TransferLog</a></li>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor </ul>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <h2><a id="formats" name="formats">Custom Log Formats</a></h2>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The format argument to the <code>LogFormat</code> and
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <code>CustomLog</code> directives is a string. This string is
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor logged to the log file for each request. It can contain literal
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor characters copied into the log files and the c-type control
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor characters "\n" and "\t" to represent new-lines and tabs.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor Literal quotes and back-slashes should be escaped with
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor back-slashes.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The characteristics of the request itself are logged by
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor placing "%" directives in the format string, which are replaced
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor in the log file by the values as follows:</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor<pre>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...a: Remote IP-address
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...A: Local IP-address
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...B: Bytes sent, excluding HTTP headers.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...b: Bytes sent, excluding HTTP headers. In CLF format
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor i.e. a '-' rather than a 0 when no bytes are sent.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...{Foobar}C: The contents of cookie "Foobar" in the request sent to the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor server.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...D: The time taken to serve the request, in microseconds.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...{FOOBAR}e: The contents of the environment variable FOOBAR
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...f: Filename
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...h: Remote host
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...H The request protocol
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...{Foobar}i: The contents of Foobar: header line(s) in the request
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor sent to the server.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...l: Remote logname (from identd, if supplied)
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...m The request method
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...{Foobar}n: The contents of note "Foobar" from another module.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...{Foobar}o: The contents of Foobar: header line(s) in the reply.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...p: The canonical Port of the server serving the request
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...P: The process ID of the child that serviced the request.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...q The query string (prepended with a ? if a query string exists,
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor otherwise an empty string)
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...r: First line of request
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...s: Status. For requests that got internally redirected, this is
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor the status of the *original* request --- %...&gt;s for the last.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...t: Time, in common log format time format (standard english format)
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...{format}t: The time, in the form given by format, which should
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor be in strftime(3) format. (potentially localized)
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...T: The time taken to serve the request, in seconds.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...u: Remote user (from auth; may be bogus if return status (%s) is 401)
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...U: The URL path requested, not including any query string.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...v: The canonical ServerName of the server serving the request.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...V: The server name according to the UseCanonicalName setting.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor%...X: Connection status when response is completed.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor 'X' = connection aborted before the response completed.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor '+' = connection may be kept alive after the response is sent.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor '-' = connection will be closed after the response is sent.
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor (This directive was %...c in late versions of Apache 1.3, but
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor this conflicted with the historical ssl %...{var}c syntax.)
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor</pre>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The "..." can be nothing at all (<em>e.g.</em>, <code>"%h %u
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor %r %s %b"</code>), or it can indicate conditions for inclusion
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor of the item (which will cause it to be replaced with "-" if the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor condition is not met). The forms of condition are a list of
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor HTTP status codes, which may or may not be preceded by "!".
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor Thus, "%400,501{User-agent}i" logs User-agent: on 400 errors
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor and 501 errors (Bad Request, Not Implemented) only;
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor "%!200,304,302{Referer}i" logs Referer: on all requests which
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor did <strong>not</strong> return some sort of normal status.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>Note that there is no escaping performed on the strings from
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor %...r, %...i and %...o. This is mainly to comply with the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor requirements of the Common Log Format. This implies that
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor clients can insert control characters into the log, so care
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor should be taken when dealing with raw log files.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>Some commonly used log format strings are:</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dl>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dt>Common Log Format (CLF)</dt>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dd><code>"%h %l %u %t \"%r\" %&gt;s %b"</code></dd>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dt>Common Log Format with Virtual Host</dt>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dd><code>"%v %h %l %u %t \"%r\" %&gt;s %b"</code></dd>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dt>NCSA extended/combined log format</dt>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dd><code>"%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor \"%{User-agent}i\""</code></dd>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dt>Referer log format</dt>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dd><code>"%{Referer}i -&gt; %U"</code></dd>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dt>Agent (Browser) log format</dt>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dd><code>"%{User-agent}i"</code></dd>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor </dl>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>Note that the canonical <a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor href="core.html#servername">ServerName</a> and <a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor href="mpm_common.html#listen">Listen</a> of the server serving the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor request are used for <code>%v</code> and <code>%p</code>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor respectively. This happens regardless of the <a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor href="core.html#usecanonicalname">UseCanonicalName</a> setting
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor because otherwise log analysis programs would have to duplicate
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor the entire vhost matching algorithm in order to decide what
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor host really served the request.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <h2>Security Considerations</h2>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>See the <a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor href="/misc/security_tips.html#serverroot">security tips</a>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor document for details on why your security could be compromised
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor if the directory where logfiles are stored is writable by
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor anyone other than the user that starts the server.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <hr />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <h2><a id="cookielog" name="cookielog">CookieLog</a>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor directive</h2>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <!--%plaintext &lt;?INDEX {\tt CookieLog} directive&gt; -->
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p><a href="directive-dict.html#Syntax"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Syntax:</strong></a> CookieLog
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <em>filename</em><br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Context"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Context:</strong></a> server config, virtual
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor host<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Module"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Module:</strong></a> mod_cookies<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Compatibility"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Compatibility:</strong></a> Only available
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor in Apache 1.2 and above</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The CookieLog directive sets the filename for logging of
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor cookies. The filename is relative to the <a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor href="core.html#serverroot">ServerRoot</a>. This directive is
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor included only for compatibility with mod_cookies, and is
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor deprecated.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <hr />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <h2><a id="customlog" name="customlog">CustomLog</a> <a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor id="customlogconditional"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor name="customlogconditional">directive</a></h2>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p><a href="directive-dict.html#Syntax"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Syntax:</strong></a> CustomLog
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <em>file</em>|<em>pipe</em> <em>format</em>|<em>nickname</em>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor [env=[!]<em>environment-variable</em>]<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Context"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Context:</strong></a> server config, virtual
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor host<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Status"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Status:</strong></a> Base<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Compatibility"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Compatibility:</strong></a> Nickname only
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor available in Apache 1.3 or later. Conditional logging available
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor in 1.3.5 or later.<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Module"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Module:</strong></a> mod_log_config</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The <code>CustomLog</code> directive is used to log requests
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor to the server. A log format is specified, and the logging can
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor optionally be made conditional on request characteristics using
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor environment variables.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The first argument, which specifies the location to which
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor the logs will be written, can take on one of the following two
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor types of values:</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dl>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dt><em>file</em></dt>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dd>A filename, relative to the <a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor href="core.html#serverroot">ServerRoot</a>.</dd>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dt><em>pipe</em></dt>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <dd>The pipe character "<code>|</code>", followed by the path
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor to a program to receive the log information on its standard
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor input. <strong>Security:</strong> if a program is used, then
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor it will be run under the user who started httpd. This will be
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor root if the server was started by root; be sure that the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor program is secure.</dd>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor </dl>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The second argument specifies what will be written to the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor log file. It can specify either a <em>nickname</em> defined by
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor a previous <a href="#logformat">LogFormat</a> directive, or it
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor can be an explicit <em>format</em> string as described in the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="#formats">log formats</a> section.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>For example, the following two sets of directives have
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor exactly the same effect:</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor<pre>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor # CustomLog with format nickname
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor CustomLog logs/access_log common
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor # CustomLog with explicit format string
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor CustomLog logs/access_log "%h %l %u %t \"%r\" %&gt;s %b"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor</pre>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The third argument is optional and allows the decision on
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor whether or not to log a particular request to be based on the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor presence or absence of a particular variable in the server
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor environment. If the specified <a href="/env.html">environment
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor variable</a> is set for the request (or is not set, in the case
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor of a '<code>env=!<em>name</em></code>' clause), then the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor request will be logged.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>Environment variables can be set on a <em>per</em>-request
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor basis using the <a href="mod_setenvif.html">mod_setenvif</a>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor and/or <a href="mod_rewrite.html">mod_rewrite</a> modules. For
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor example, if you don't want to record requests for all GIF
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor images on your server in a separate logfile but not your main
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor log, you can use:</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor<pre>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor SetEnvIf Request_URI \.gif$ gif-image
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor CustomLog gif-requests.log common env=gif-image
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor CustomLog nongif-requests.log common env=!gif-image
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor</pre>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <hr />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <h2><a id="logexcludebytype" name="logexcludebytype">LogExcludeByType</a> directive</h2>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p><a href="directive-dict.html#Syntax"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Syntax:</strong></a> LogExcludeByType
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor "<em>mimetype</em> <em>mimetype</em> <em>...</em>" [env=[!]<em>environment-variable</em>]<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Context"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Context:</strong></a> server config, virtual
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor host<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Status"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Status:</strong></a> Base<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Compatibility"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Compatibility:</strong></a> only
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor available in Apache 2.0.31 or later. <br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Module"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Module:</strong></a> mod_log_config</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The <code>LogExcludeByType</code> directive is used to not log requests
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor of certain types of files. for example, you may not want to log requests for
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor all the gif images on your site</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The first argument, which specifies the mime types to ignore. These values
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor are space seperated and are in the simliar to image/gif. (To figure out what mime
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor type a certain file is, try looking at the request headers it returns where you request it)
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The third argument is optional and allows the decision on
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor whether or not to log a particular request to be based on the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor presence or absence of a particular variable in the server
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor environment. If the specified <a href="/env.html">environment
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor variable</a> is set for the request (or is not set, in the case
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor of a '<code>env=!<em>name</em></code>' clause), then the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor request will be logged.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <hr />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <h2><a id="logformat" name="logformat">LogFormat</a>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor directive</h2>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <!--%plaintext &lt;?INDEX {\tt LogFormat} directive&gt; -->
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p><a href="directive-dict.html#Syntax"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Syntax:</strong></a> LogFormat
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <em>format</em>|<em>nickname</em> [<em>nickname</em>]<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Default"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Default:</strong></a> <code>LogFormat "%h %l
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor %u %t \"%r\" %&gt;s %b"</code><br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Context"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Context:</strong></a> server config, virtual
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor host<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Status"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Status:</strong></a> Base<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Compatibility"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Compatibility:</strong></a> Nickname only
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor available in Apache 1.3 or later<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Module"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Module:</strong></a> mod_log_config</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>This directive specifies the format of the access log
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor file.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The <code>LogFormat</code> directive can take one of two
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor forms. In the first form, where only one argument is specified,
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor this directive sets the log format which will be used by logs
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor specified in subsequent <a href="#transferlog">TransferLog</a>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor directives. The single argument can specify an explicit
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <em>format</em> as discussed in <a href="#formats">custom log
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor formats</a> section above. Alternatively, it can use a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <em>nickname</em> to refer to a log format defined in a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor previous <code>LogFormat</code> directive as described
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor below.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>The second form of the <code>LogFormat</code> directive
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor associates an explicit <em>format</em> with a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <em>nickname</em>. This <em>nickname</em> can then be used in
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor subsequent <code>LogFormat</code> or <a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor href="#customlog">CustomLog</a> directives rather than
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor repeating the entire format string. A <samp>LogFormat</samp>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor directive which defines a nickname <strong>does nothing
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor else</strong> -- that is, it <em>only</em> defines the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor nickname, it doesn't actually apply the format and make it the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor default. Therefore, it will not affect subsequent <a
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor href="#transferlog">TransferLog</a> directives.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <hr />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <h2><a id="transferlog" name="transferlog">TransferLog</a>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor directive</h2>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <!--%plaintext &lt;?INDEX {\tt TransferLog} directive&gt; -->
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p><a href="directive-dict.html#Syntax"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Syntax:</strong></a> TransferLog
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <em>file</em>|<em>pipe</em><br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Default"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Default:</strong></a> none<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Context"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Context:</strong></a> server config, virtual
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor host<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Status"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Status:</strong></a> Base<br />
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <a href="directive-dict.html#Module"
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor rel="Help"><strong>Module:</strong></a> mod_log_config</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>This directive has exactly the same arguments and effect as
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor the <a href="#customlog">CustomLog</a> directive, with the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor exception that it does not allow the log format to be specified
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor explicitly or for conditional logging of requests. Instead, the
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor log format is determined by the most recently specified
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor specified <a href="#logformat">LogFormat</a> directive (which
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor does not define a nickname). Common Log Format is used if no
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor other format has been specified.</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <p>Example:</p>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor<pre>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-agent}i\""
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor TransferLog logs/access_log
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor</pre>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor <!--#include virtual="footer.html" -->
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor </body>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor</html>
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor
293aa6caecb1db771e9baa2f79c92f1c381caee4gryzor