mod_log_config.xml revision 2bac697634d965d9d9a921a99a68b2c454c8a95d
6c822625991844de5475569ff656a69965aa6affrbowen<?xml version="1.0"?>
c3fcea07965f59723831e23da647a77518285b8eslive<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
e942c741056732f50da2074b36fe59805d370650slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
6c822625991844de5475569ff656a69965aa6affrbowen<modulesynopsis>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen<name>mod_log_config</name>
c3fcea07965f59723831e23da647a77518285b8eslive<description>Logging of the requests made to the server</description>
6c822625991844de5475569ff656a69965aa6affrbowen<status>Base</status>
c3fcea07965f59723831e23da647a77518285b8eslive<sourcefile>mod_log_config.c</sourcefile>
6c822625991844de5475569ff656a69965aa6affrbowen<identifier>log_config_module</identifier>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen<summary>
6c822625991844de5475569ff656a69965aa6affrbowen <p>This module provides for flexible logging of client
6c822625991844de5475569ff656a69965aa6affrbowen requests. Logs are written in a customizable format, and may be
6c822625991844de5475569ff656a69965aa6affrbowen written directly to a file, or to an external program.
6c822625991844de5475569ff656a69965aa6affrbowen Conditional logging is provided so that individual requests may
6c822625991844de5475569ff656a69965aa6affrbowen be included or excluded from the logs based on characteristics
6c822625991844de5475569ff656a69965aa6affrbowen of the request.</p>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <p>Three directives are provided by this module:
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <directive module="mod_log_config">TransferLog</directive> to create
10542e490a1b0abf5c02e022f29ea2074ca4d435nd a log file, <directive module="mod_log_config">LogFormat</directive>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd to set a custom format, and <directive module="mod_log_config"
10542e490a1b0abf5c02e022f29ea2074ca4d435nd >CustomLog</directive> to define a log file and format in one
10542e490a1b0abf5c02e022f29ea2074ca4d435nd step. The <directive>TransferLog</directive> and <directive
10542e490a1b0abf5c02e022f29ea2074ca4d435nd >CustomLog</directive> directives can be used multiple times in each
10542e490a1b0abf5c02e022f29ea2074ca4d435nd server to cause each request to be logged to multiple files.</p>
c3fcea07965f59723831e23da647a77518285b8eslive</summary>
c3fcea07965f59723831e23da647a77518285b8eslive<seealso><a href="/logs.html">Apache Log Files</a></seealso>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<section id="formats"><title>Custom Log Formats</title>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <p>The format argument to the <directive module="mod_log_config"
10542e490a1b0abf5c02e022f29ea2074ca4d435nd >LogFormat</directive> and <directive module="mod_log_config"
10542e490a1b0abf5c02e022f29ea2074ca4d435nd >CustomLog</directive> directives is a string. This string is
6c822625991844de5475569ff656a69965aa6affrbowen logged to the log file for each request. It can contain literal
6c822625991844de5475569ff656a69965aa6affrbowen characters copied into the log files and the c-type control
6c822625991844de5475569ff656a69965aa6affrbowen characters "\n" and "\t" to represent new-lines and tabs.
6c822625991844de5475569ff656a69965aa6affrbowen Literal quotes and back-slashes should be escaped with
6c822625991844de5475569ff656a69965aa6affrbowen back-slashes.</p>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <p>The characteristics of the request itself are logged by
10542e490a1b0abf5c02e022f29ea2074ca4d435nd placing "<code>%</code>" directives in the format string, which are
10542e490a1b0abf5c02e022f29ea2074ca4d435nd replaced in the log file by the values as follows:</p>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <table border="1" style="zebra">
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><th>Format&nbsp;String</th>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <th>Description</th></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
d883f484445c69235c496cb800d918a4fcc94fe8nd <tr><td><code>%%</code></td>
d883f484445c69235c496cb800d918a4fcc94fe8nd <td>The percent sign</td></tr>
d883f484445c69235c496cb800d918a4fcc94fe8nd
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...a</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Remote IP-address</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...A</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Local IP-address</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...B</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Bytes sent, excluding HTTP headers.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...b</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Bytes sent, excluding HTTP headers. In CLF format, <em>i.e.</em>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd a '<code>-</code>' rather than a 0 when no bytes are sent.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...{<var>Foobar</var>}C</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The contents of cookie <var>Foobar</var> in the request sent
10542e490a1b0abf5c02e022f29ea2074ca4d435nd to the server.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...D</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The time taken to serve the request, in microseconds.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...{<var>FOOBAR</var>}e</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The contents of the environment variable
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <var>FOOBAR</var></td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...f</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Filename</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...h</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Remote host</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...H</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The request protocol</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...{<var>Foobar</var>}i</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The contents of <code><var>Foobar</var>:</code> header line(s)
10542e490a1b0abf5c02e022f29ea2074ca4d435nd in the request sent to the server.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...l</code></td>
77b840c850ef60fd6a119f3a7e907412d78b77d5nd <td>Remote logname (from identd, if supplied). This will return a
77b840c850ef60fd6a119f3a7e907412d78b77d5nd dash unless <module>mod_ident</module> is present and <directive
77b840c850ef60fd6a119f3a7e907412d78b77d5nd module="mod_ident">IdentityCheck</directive> is set
77b840c850ef60fd6a119f3a7e907412d78b77d5nd <code>On</code>.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...m</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The request method</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...{<var>Foobar</var>}n</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The contents of note <var>Foobar</var> from another
10542e490a1b0abf5c02e022f29ea2074ca4d435nd module.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...{<var>Foobar</var>}o</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The contents of <code><var>Foobar</var>:</code> header line(s)
10542e490a1b0abf5c02e022f29ea2074ca4d435nd in the reply.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...p</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The canonical port of the server serving the request</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...P</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The process ID of the child that serviced the request.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...q</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The query string (prepended with a <code>?</code> if a query
10542e490a1b0abf5c02e022f29ea2074ca4d435nd string exists, otherwise an empty string)</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...r</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>First line of request</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...s</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Status. For requests that got internally redirected, this is
10542e490a1b0abf5c02e022f29ea2074ca4d435nd the status of the *original* request --- <code>%...&gt;s</code>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd for the last.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...t</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Time, in common log format time format (standard english
10542e490a1b0abf5c02e022f29ea2074ca4d435nd format)</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...{<var>format</var>}t</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The time, in the form given by format, which should be in
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <code>strftime(3)</code> format. (potentially localized)</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...T</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The time taken to serve the request, in seconds.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...u</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Remote user (from auth; may be bogus if return status
10542e490a1b0abf5c02e022f29ea2074ca4d435nd (<code>%s</code>) is 401)</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...U</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The URL path requested, not including any query string.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...v</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The canonical <directive module="core">ServerName</directive>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd of the server serving the request.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...V</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>The server name according to the <directive module="core"
10542e490a1b0abf5c02e022f29ea2074ca4d435nd >UseCanonicalName</directive> setting.</td></tr>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...X</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Connection status when response is completed:
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <table>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>X</code> =</td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>connection aborted before the response completed.</td></tr>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>+</code> =</td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>connection may be kept alive after the response is
10542e490a1b0abf5c02e022f29ea2074ca4d435nd sent.</td></tr>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>-</code> = </td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>connection will be closed after the response is
10542e490a1b0abf5c02e022f29ea2074ca4d435nd sent.</td></tr>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd </table>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <p>(This directive was <code>%...c</code> in late versions of Apache
10542e490a1b0abf5c02e022f29ea2074ca4d435nd 1.3, but this conflicted with the historical ssl
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <code>%...{<var>var</var>}c</code> syntax.)</p></td></tr>
481c1206b6065a8f37ab75ca1fc26c947cb37852ianh
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...I</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Bytes received, including request and headers, cannot be zero.
10542e490a1b0abf5c02e022f29ea2074ca4d435nd You need to enable <module>mod_logio</module> to use this.</td></tr>
481c1206b6065a8f37ab75ca1fc26c947cb37852ianh
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <tr><td><code>%...O</code></td>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <td>Bytes sent, including headers, cannot be zero. You need to
10542e490a1b0abf5c02e022f29ea2074ca4d435nd enable <module>mod_logio</module> to use this.</td></tr>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd </table>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <p>The "<var>...</var>" can be nothing at all (<em>e.g.</em>,
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <code>"%h %u %r %s %b"</code>), or it can indicate conditions for
10542e490a1b0abf5c02e022f29ea2074ca4d435nd inclusion of the item (which will cause it to be replaced with "-" if
10542e490a1b0abf5c02e022f29ea2074ca4d435nd the condition is not met). The forms of condition are a list of
6c822625991844de5475569ff656a69965aa6affrbowen HTTP status codes, which may or may not be preceded by "!".
10542e490a1b0abf5c02e022f29ea2074ca4d435nd Thus, "%400,501{User-agent}i" logs <code>User-agent:</code> on 400
10542e490a1b0abf5c02e022f29ea2074ca4d435nd errors and 501 errors (Bad Request, Not Implemented) only;
10542e490a1b0abf5c02e022f29ea2074ca4d435nd "%!200,304,302{Referer}i" logs <code>Referer:</code> on all requests
10542e490a1b0abf5c02e022f29ea2074ca4d435nd which did <em>not</em> return some sort of normal status.</p>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <p>Note that there is no escaping performed on the strings from
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <code>%...r</code>, <code>%...i</code> and <code>%...o</code>. This
10542e490a1b0abf5c02e022f29ea2074ca4d435nd is mainly to comply with the requirements of the Common Log Format.
10542e490a1b0abf5c02e022f29ea2074ca4d435nd This implies that clients can insert control characters into the log,
10542e490a1b0abf5c02e022f29ea2074ca4d435nd so care should be taken when dealing with raw log files.</p>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <p>Some commonly used log format strings are:</p>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <dl>
6c822625991844de5475569ff656a69965aa6affrbowen <dt>Common Log Format (CLF)</dt>
6c822625991844de5475569ff656a69965aa6affrbowen <dd><code>"%h %l %u %t \"%r\" %&gt;s %b"</code></dd>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <dt>Common Log Format with Virtual Host</dt>
6c822625991844de5475569ff656a69965aa6affrbowen <dd><code>"%v %h %l %u %t \"%r\" %&gt;s %b"</code></dd>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <dt>NCSA extended/combined log format</dt>
6c822625991844de5475569ff656a69965aa6affrbowen <dd><code>"%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\"
6c822625991844de5475569ff656a69965aa6affrbowen \"%{User-agent}i\""</code></dd>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <dt>Referer log format</dt>
6c822625991844de5475569ff656a69965aa6affrbowen <dd><code>"%{Referer}i -&gt; %U"</code></dd>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <dt>Agent (Browser) log format</dt>
6c822625991844de5475569ff656a69965aa6affrbowen <dd><code>"%{User-agent}i"</code></dd>
6c822625991844de5475569ff656a69965aa6affrbowen </dl>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <p>Note that the canonical <directive module="core"
10542e490a1b0abf5c02e022f29ea2074ca4d435nd >ServerName</directive> and <directive module="mpm_common"
10542e490a1b0abf5c02e022f29ea2074ca4d435nd >Listen</directive> of the server serving the
6c822625991844de5475569ff656a69965aa6affrbowen request are used for <code>%v</code> and <code>%p</code>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd respectively. This happens regardless of the <directive
10542e490a1b0abf5c02e022f29ea2074ca4d435nd module="core">UseCanonicalName</directive> setting
6c822625991844de5475569ff656a69965aa6affrbowen because otherwise log analysis programs would have to duplicate
6c822625991844de5475569ff656a69965aa6affrbowen the entire vhost matching algorithm in order to decide what
6c822625991844de5475569ff656a69965aa6affrbowen host really served the request.</p>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd</section>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<section id="security"><title>Security Considerations</title>
6c822625991844de5475569ff656a69965aa6affrbowen <p>See the <a
6c822625991844de5475569ff656a69965aa6affrbowen href="/misc/security_tips.html#serverroot">security tips</a>
6c822625991844de5475569ff656a69965aa6affrbowen document for details on why your security could be compromised
6c822625991844de5475569ff656a69965aa6affrbowen if the directory where logfiles are stored is writable by
6c822625991844de5475569ff656a69965aa6affrbowen anyone other than the user that starts the server.</p>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd</section>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen<directivesynopsis>
6c822625991844de5475569ff656a69965aa6affrbowen<name>CookieLog</name>
6c822625991844de5475569ff656a69965aa6affrbowen<description>Sets filename for the logging of cookies</description>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<syntax>CookieLog <var>filename</var></syntax>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<contextlist><context>server config</context><context>virtual host</context>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd</contextlist>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<compatibility>This directive is deprecated.</compatibility>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen<usage>
6c822625991844de5475569ff656a69965aa6affrbowen <p>The <directive>CookieLog</directive> directive sets the
6c822625991844de5475569ff656a69965aa6affrbowen filename for logging of cookies. The filename is relative to the
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <directive module="core">ServerRoot</directive>. This directive is
199a8ee5984e3708982fab1ba6ebb0a5feaea90cnd included only for compatibility with <code>mod_cookies</code>,
6c822625991844de5475569ff656a69965aa6affrbowen and is deprecated.</p>
6c822625991844de5475569ff656a69965aa6affrbowen</usage>
6c822625991844de5475569ff656a69965aa6affrbowen</directivesynopsis>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen<directivesynopsis>
6c822625991844de5475569ff656a69965aa6affrbowen<name>CustomLog</name>
6c822625991844de5475569ff656a69965aa6affrbowen<description>Sets filename and format of log file</description>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<syntax>CustomLog <var>file</var>|<var>pipe</var>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<var>format</var>|<var>nickname</var>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd[env=[!]<var>environment-variable</var>]</syntax>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<contextlist><context>server config</context><context>virtual host</context>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd</contextlist>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen<usage>
6c822625991844de5475569ff656a69965aa6affrbowen <p>The <directive>CustomLog</directive> directive is used to
6c822625991844de5475569ff656a69965aa6affrbowen log requests to the server. A log format is specified, and the
6c822625991844de5475569ff656a69965aa6affrbowen logging can optionally be made conditional on request
6c822625991844de5475569ff656a69965aa6affrbowen characteristics using environment variables.</p>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <p>The first argument, which specifies the location to which
6c822625991844de5475569ff656a69965aa6affrbowen the logs will be written, can take on one of the following two
6c822625991844de5475569ff656a69965aa6affrbowen types of values:</p>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <dl>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <dt><var>file</var></dt>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <dd>A filename, relative to the <directive module="core"
10542e490a1b0abf5c02e022f29ea2074ca4d435nd >ServerRoot</directive>.</dd>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <dt><var>pipe</var></dt>
6c822625991844de5475569ff656a69965aa6affrbowen <dd>The pipe character "<code>|</code>", followed by the path
6c822625991844de5475569ff656a69965aa6affrbowen to a program to receive the log information on its standard
10542e490a1b0abf5c02e022f29ea2074ca4d435nd input.
10542e490a1b0abf5c02e022f29ea2074ca4d435nd
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <note type="warning"><title>Security:</title>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <p>If a program is used, then it will be run under the user who
10542e490a1b0abf5c02e022f29ea2074ca4d435nd started httpd. This will be root if the server was started by root;
10542e490a1b0abf5c02e022f29ea2074ca4d435nd be sure that the program is secure.</p>
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholes </note>
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholes <note type="warning"><title>Note</title>
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholes <p>When entering a file path on non-Unix platforms, care should be taken
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholes to make sure that only forward slashed are used even though the platform
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholes may allow the use of back slashes. In general it is a good idea to always
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholes use forward slashes throughout the configuration files.</p>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd </note></dd>
6c822625991844de5475569ff656a69965aa6affrbowen </dl>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <p>The second argument specifies what will be written to the
10542e490a1b0abf5c02e022f29ea2074ca4d435nd log file. It can specify either a <var>nickname</var> defined by
10542e490a1b0abf5c02e022f29ea2074ca4d435nd a previous <directive module="mod_log_config">LogFormat</directive>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd directive, or it can be an explicit <var>format</var> string as
10542e490a1b0abf5c02e022f29ea2074ca4d435nd described in the <a href="#formats">log formats</a> section.</p>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <p>For example, the following two sets of directives have
6c822625991844de5475569ff656a69965aa6affrbowen exactly the same effect:</p>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <example>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd # CustomLog with format nickname<br />
10542e490a1b0abf5c02e022f29ea2074ca4d435nd LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common<br />
10542e490a1b0abf5c02e022f29ea2074ca4d435nd CustomLog logs/access_log common<br />
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <br />
10542e490a1b0abf5c02e022f29ea2074ca4d435nd # CustomLog with explicit format string<br />
10542e490a1b0abf5c02e022f29ea2074ca4d435nd CustomLog logs/access_log "%h %l %u %t \"%r\" %&gt;s %b"
10542e490a1b0abf5c02e022f29ea2074ca4d435nd </example>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <p>The third argument is optional and allows the decision on
6c822625991844de5475569ff656a69965aa6affrbowen whether or not to log a particular request to be based on the
6c822625991844de5475569ff656a69965aa6affrbowen presence or absence of a particular variable in the server
6c822625991844de5475569ff656a69965aa6affrbowen environment. If the specified <a href="/env.html">environment
6c822625991844de5475569ff656a69965aa6affrbowen variable</a> is set for the request (or is not set, in the case
10542e490a1b0abf5c02e022f29ea2074ca4d435nd of a '<code>env=!<var>name</var></code>' clause), then the
6c822625991844de5475569ff656a69965aa6affrbowen request will be logged.</p>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <p>Environment variables can be set on a per-request
6c822625991844de5475569ff656a69965aa6affrbowen basis using the <module>mod_setenvif</module>
6c822625991844de5475569ff656a69965aa6affrbowen and/or <module>mod_rewrite</module> modules. For
01814afd8daa1fb017fcb956ac01d173763f896eyoshiki example, if you want to record requests for all GIF
01814afd8daa1fb017fcb956ac01d173763f896eyoshiki images on your server in a separate logfile but not in your main
6c822625991844de5475569ff656a69965aa6affrbowen log, you can use:</p>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <example>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd SetEnvIf Request_URI \.gif$ gif-image<br />
10542e490a1b0abf5c02e022f29ea2074ca4d435nd CustomLog gif-requests.log common env=gif-image<br />
10542e490a1b0abf5c02e022f29ea2074ca4d435nd CustomLog nongif-requests.log common env=!gif-image
10542e490a1b0abf5c02e022f29ea2074ca4d435nd </example>
6c822625991844de5475569ff656a69965aa6affrbowen</usage>
6c822625991844de5475569ff656a69965aa6affrbowen</directivesynopsis>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen<directivesynopsis>
6c822625991844de5475569ff656a69965aa6affrbowen<name>LogFormat</name>
6c822625991844de5475569ff656a69965aa6affrbowen<description>Describes a format for use in a log file</description>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<syntax>LogFormat <var>format</var>|<var>nickname</var>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd[<var>nickname</var>]</syntax>
7cb7b06acc8700479d4d4080b8c7bc5278f20028slive<default>LogFormat "%h %l %u %t \"%r\" %>s %b"</default>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<contextlist><context>server config</context><context>virtual host</context>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd</contextlist>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen<usage>
6c822625991844de5475569ff656a69965aa6affrbowen <p>This directive specifies the format of the access log
6c822625991844de5475569ff656a69965aa6affrbowen file.</p>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <p>The <directive>LogFormat</directive> directive can take one of two
6c822625991844de5475569ff656a69965aa6affrbowen forms. In the first form, where only one argument is specified,
6c822625991844de5475569ff656a69965aa6affrbowen this directive sets the log format which will be used by logs
6c822625991844de5475569ff656a69965aa6affrbowen specified in subsequent <directive>TransferLog</directive>
6c822625991844de5475569ff656a69965aa6affrbowen directives. The single argument can specify an explicit
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <var>format</var> as discussed in <a href="#formats">custom log
6c822625991844de5475569ff656a69965aa6affrbowen formats</a> section above. Alternatively, it can use a
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <var>nickname</var> to refer to a log format defined in a
6c822625991844de5475569ff656a69965aa6affrbowen previous <directive>LogFormat</directive> directive as described
6c822625991844de5475569ff656a69965aa6affrbowen below.</p>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen <p>The second form of the <directive>LogFormat</directive>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd directive associates an explicit <var>format</var> with a
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <var>nickname</var>. This <var>nickname</var> can then be used in
6c822625991844de5475569ff656a69965aa6affrbowen subsequent <directive>LogFormat</directive> or
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <directive module="mod_log_config">CustomLog</directive> directives
10542e490a1b0abf5c02e022f29ea2074ca4d435nd rather than repeating the entire format string. A
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <directive>LogFormat</directive> directive that defines a nickname
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <strong>does nothing else</strong> -- that is, it <em>only</em>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd defines the nickname, it doesn't actually apply the format and make
10542e490a1b0abf5c02e022f29ea2074ca4d435nd it the default. Therefore, it will not affect subsequent
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <directive module="mod_log_config">TransferLog</directive> directives.
10542e490a1b0abf5c02e022f29ea2074ca4d435nd In addition, <directive>LogFormat</directive> cannot use one nickname
10542e490a1b0abf5c02e022f29ea2074ca4d435nd to define another nickname. Note, that the nickname should not contain
10542e490a1b0abf5c02e022f29ea2074ca4d435nd percent signs (<code>%</code>).</p>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <example><title>Example</title>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd LogFormat "%v %h %l %u %t \"%r\" %&gt;s %b" vhost_common
10542e490a1b0abf5c02e022f29ea2074ca4d435nd </example>
6c822625991844de5475569ff656a69965aa6affrbowen</usage>
6c822625991844de5475569ff656a69965aa6affrbowen</directivesynopsis>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen<directivesynopsis>
6c822625991844de5475569ff656a69965aa6affrbowen<name>TransferLog</name>
6c822625991844de5475569ff656a69965aa6affrbowen<description>Specifly location of a log file</description>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<syntax>TransferLog <var>file</var>|<var>pipe</var></syntax>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd<contextlist><context>server config</context><context>virtual host</context>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd</contextlist>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen<usage>
6c822625991844de5475569ff656a69965aa6affrbowen <p>This directive has exactly the same arguments and effect as
10542e490a1b0abf5c02e022f29ea2074ca4d435nd the <directive module="mod_log_config">CustomLog</directive>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd directive, with the exception that it does not allow the log format
10542e490a1b0abf5c02e022f29ea2074ca4d435nd to be specified explicitly or for conditional logging of requests.
10542e490a1b0abf5c02e022f29ea2074ca4d435nd Instead, the log format is determined by the most recently specified
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <directive module="mod_log_config">LogFormat</directive> directive
10542e490a1b0abf5c02e022f29ea2074ca4d435nd (which does not define a nickname). Common Log Format is used if no
6c822625991844de5475569ff656a69965aa6affrbowen other format has been specified.</p>
6c822625991844de5475569ff656a69965aa6affrbowen
10542e490a1b0abf5c02e022f29ea2074ca4d435nd <example><title>Example</title>
10542e490a1b0abf5c02e022f29ea2074ca4d435nd LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-agent}i\""<br />
10542e490a1b0abf5c02e022f29ea2074ca4d435nd TransferLog logs/access_log
10542e490a1b0abf5c02e022f29ea2074ca4d435nd </example>
6c822625991844de5475569ff656a69965aa6affrbowen</usage>
6c822625991844de5475569ff656a69965aa6affrbowen</directivesynopsis>
6c822625991844de5475569ff656a69965aa6affrbowen
6c822625991844de5475569ff656a69965aa6affrbowen</modulesynopsis>