<html xmlns="http://www.w3.org/TR/xhtml1/strict"><head><!-- 
          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                This file is generated from xml source: DO NOT EDIT
          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        --><title>mod_log_config- Apache HTTP Server</title><link href="../style/manual.css" type="text/css" rel="stylesheet"/></head><body><blockquote><div align="center"><img src="../images/sub.gif" alt="[APACHE DOCUMENTATION]"/><h3>Apache HTTP Server Version 2.0</h3></div><h1 align="center">Apache Module mod_log_config</h1><table cellspacing="1" cellpadding="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td valign="top"><span class="help">Description:</span></td><td>Logging of the requests made to the server</td></tr><tr><td><a href="module-dict.html#Status" class="help">Status:</a></td><td>Base</td></tr><tr><td><a href="module-dict.html#ModuleIdentifier" class="help">Module&nbsp;Identifier:</a></td><td>log_config_module</td></tr></table></td></tr></table><h2>Summary</h2>

    <p>This module provides for flexible logging of client
    requests. Logs are written in a customizable format, and may be
    written directly to a file, or to an external program.
    Conditional logging is provided so that individual requests may
    be included or excluded from the logs based on characteristics
    of the request.</p>

    <p>Three directives are provided by this module:
    <code>TransferLog</code> to create a log file,
    <code>LogFormat</code> to set a custom format, and
    <code>CustomLog</code> to define a log file and format in one
    step. The <code>TransferLog</code> and <code>CustomLog</code>
    directives can be used multiple times in each server to cause
    each request to be logged to multiple files.</p>
<h2>Directives</h2><ul><li><a href="#cookielog">CookieLog</a></li><li><a href="#customlog">CustomLog</a></li><li><a href="#logformat">LogFormat</a></li><li><a href="#transferlog">TransferLog</a></li></ul><p><strong>See also </strong></p><ul><li><a href="../logs.html">Apache Log Files</a></li></ul><h2><a name="formats">Custom Log Formats</a></h2>


    <p>The format argument to the <code>LogFormat</code> and
    <code>CustomLog</code> directives is a string. This string is
    logged to the log file for each request. It can contain literal
    characters copied into the log files and the c-type control
    characters "\n" and "\t" to represent new-lines and tabs.
    Literal quotes and back-slashes should be escaped with
    back-slashes.</p>

    <p>The characteristics of the request itself are logged by
    placing "%" directives in the format string, which are replaced
    in the log file by the values as follows:</p>

<table>

<tr><td>%...a:</td>          
<td>Remote IP-address</td></tr>

<tr><td>%...A:</td>          
<td>Local IP-address</td></tr>

<tr><td>%...B:</td>          
<td>Bytes sent, excluding HTTP headers.</td></tr>

<tr><td>%...b:</td>          
<td>Bytes sent, excluding HTTP headers. In CLF format
i.e. a '-' rather than a 0 when no bytes are sent.</td></tr>

<tr><td>%...{Foobar}C:</td>  
<td>The contents of cookie "Foobar" in the request sent to the server.</td></tr>

<tr><td>%...D:</td>          
<td>The time taken to serve the request, in microseconds.</td></tr>

<tr><td>%...{FOOBAR}e:</td>  
<td>The contents of the environment variable FOOBAR</td></tr>

<tr><td>%...f:</td>          
<td>Filename</td></tr>

<tr><td>%...h:</td>          
<td>Remote host</td></tr>

<tr><td>%...H</td>          
<td>The request protocol</td></tr>

<tr><td>%...{Foobar}i:</td>  
<td>The contents of Foobar: header line(s) in the request
sent to the server.</td></tr>

<tr><td>%...l:</td>          
<td>Remote logname (from identd, if supplied)</td></tr>

<tr><td>%...m:</td>          
<td>The request method</td></tr>

<tr><td>%...{Foobar}n:</td>  
<td>The contents of note "Foobar" from another module.</td></tr>

<tr><td>%...{Foobar}o:</td>  
<td>The contents of Foobar: header line(s) in the reply.</td></tr>

<tr><td>%...p:</td>          
<td>The canonical Port of the server serving the request</td></tr>

<tr><td>%...P:</td>          
<td>The process ID of the child that serviced the request.</td></tr>

<tr><td>%...q:</td>          
<td>The query string (prepended with a ? if a query string exists,
otherwise an empty string)</td></tr>

<tr><td>%...r:</td>          
<td>First line of request</td></tr>

<tr><td>%...s:</td>          
<td>Status.  For requests that got internally redirected, this is
the status of the *original* request --- %...&gt;s for the last.</td></tr>

<tr><td>%...t:</td>          
<td>Time, in common log format time format (standard english format)</td></tr>

<tr><td>%...{format}t:</td>  
<td>The time, in the form given by format, which should
be in strftime(3) format. (potentially localized)</td></tr>

<tr><td>%...T:</td>          
<td>The time taken to serve the request, in seconds.</td></tr>

<tr><td>%...u:</td>          
<td>Remote user (from auth; may be bogus if return status (%s) is 401)</td></tr>

<tr><td>%...U:</td>          
<td>The URL path requested, not including any query string.</td></tr>

<tr><td>%...v:</td>          
<td>The canonical ServerName of the server serving the request.</td></tr>

<tr><td>%...V:</td>          
<td>The server name according to the UseCanonicalName setting.</td></tr>

<tr><td>%...X:</td>          
<td>Connection status when response is completed.
<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
'X' = connection aborted before the response completed.<br>
'+' = connection may be kept alive after the response is sent.<br>
'-' = connection will be closed after the response is sent.
</code></td></tr></table></blockquote>
<blockquote><table><tr><td bgcolor="#e0e5f5">(This directive was %...c in late versions of Apache 1.3, but
this conflicted with the historical ssl %...{var}c syntax.)</td></tr></table></blockquote>
</td></tr>

</table>

    <p>The "..." can be nothing at all (<em>e.g.</em>, <code>"%h %u
    %r %s %b"</code>), or it can indicate conditions for inclusion
    of the item (which will cause it to be replaced with "-" if the
    condition is not met). 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 <strong>not</strong> return some sort of normal status.</p>

    <p>Note that there is no escaping performed on the strings from
    %...r, %...i and %...o. This is mainly to comply with the
    requirements of the Common Log Format. This implies that
    clients can insert control characters into the log, so care
    should be taken when dealing with raw log files.</p>

    <p>Some commonly used log format strings are:</p>

    <dl>
      <dt>Common Log Format (CLF)</dt>

      <dd><code>"%h %l %u %t \"%r\" %&gt;s %b"</code></dd>

      <dt>Common Log Format with Virtual Host</dt>

      <dd><code>"%v %h %l %u %t \"%r\" %&gt;s %b"</code></dd>

      <dt>NCSA extended/combined log format</dt>

      <dd><code>"%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\"
      \"%{User-agent}i\""</code></dd>

      <dt>Referer log format</dt>

      <dd><code>"%{Referer}i -&gt; %U"</code></dd>

      <dt>Agent (Browser) log format</dt>

      <dd><code>"%{User-agent}i"</code></dd>
    </dl>

    <p>Note that the canonical <a href="core.html#servername">ServerName</a> and <a href="mpm_common.html#listen">Listen</a> of the server serving the
    request are used for <code>%v</code> and <code>%p</code>
    respectively. This happens regardless of the <a href="core.html#usecanonicalname">UseCanonicalName</a> setting
    because otherwise log analysis programs would have to duplicate
    the entire vhost matching algorithm in order to decide what
    host really served the request.</p>
    <h2>Security Considerations</h2>

    

    <p>See the <a href="../misc/security_tips.html#serverroot">security tips</a>
    document for details on why your security could be compromised
    if the directory where logfiles are stored is writable by
    anyone other than the user that starts the server.</p>

    <hr/><h2><a name="CookieLog">CookieLog</a> <a name="cookielog">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: </strong></td><td>Sets filename for the logging of cookies</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:</a></td><td>CookieLog <em>filename</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:</a></td><td>server config, virtual
host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:</a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:</a></td><td>mod_log_config</td></tr><tr><td nowrap="nowrap" align="left" valign="top"><a href="directive-dict.html#Compatibility" class="help">Compatibility:</a></td><td>Only available in Apache 1.2 and above</td></tr></table></td></tr></table>

    <p>The <code class="directive">CookieLog</code> directive sets the 
    filename for logging of cookies. The filename is relative to the
    <a href="core.html#serverroot" class="directive"><code class="directive">serverroot</code></a>. This directive is
    included only for compatibility with <code><a href="mod_cookies.html">mod_cookies</a></code>,
    and is deprecated.</p>
<hr/><h2><a name="CustomLog">CustomLog</a> <a name="customlog">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: </strong></td><td>Sets filename and format of log file</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:</a></td><td>CustomLog 
    <em>file</em>|<em>pipe</em> <em>format</em>|<em>nickname</em>
    [env=[!]<em>environment-variable</em>]</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:</a></td><td>server config, virtual
host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:</a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:</a></td><td>mod_log_config</td></tr><tr><td nowrap="nowrap" align="left" valign="top"><a href="directive-dict.html#Compatibility" class="help">Compatibility:</a></td><td>Nickname only available in Apache 1.3 or later.
Conditional logging available in 1.3.5 or later.</td></tr></table></td></tr></table>
    <p>The <code class="directive">CustomLog</code> directive is used to
    log requests to the server. A log format is specified, and the
    logging can optionally be made conditional on request
    characteristics using environment variables.</p>

    <p>The first argument, which specifies the location to which
    the logs will be written, can take on one of the following two
    types of values:</p>

    <dl>
      <dt><em>file</em></dt>

      <dd>A filename, relative to the <a href="core.html#serverroot">ServerRoot</a>.</dd>

      <dt><em>pipe</em></dt>

      <dd>The pipe character "<code>|</code>", followed by the path
      to a program to receive the log information on its standard
      input. <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.</dd>
    </dl>

    <p>The second argument specifies what will be written to the
    log file. It can specify either a <em>nickname</em> defined by
    a previous <a href="#logformat">LogFormat</a> directive, or it
    can be an explicit <em>format</em> string as described in the
    <a href="#formats">log formats</a> section.</p>

    <p>For example, the following two sets of directives have
    exactly the same effect:</p>

<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
     # CustomLog with format nickname<br>
     LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common<br>
     CustomLog logs/access_log common<br>
<br>
     # CustomLog with explicit format string<br>
     CustomLog logs/access_log "%h %l %u %t \"%r\" %&gt;s %b"<br>
</code></td></tr></table></blockquote>

    <p>The third argument is optional and allows the decision on
    whether or not to log a particular request to be based on the
    presence or absence of a particular variable in the server
    environment. If the specified <a href="../env.html">environment
    variable</a> is set for the request (or is not set, in the case
    of a '<code>env=!<em>name</em></code>' clause), then the
    request will be logged.</p>

    <p>Environment variables can be set on a <em>per</em>-request
    basis using the <code><a href="mod_setenvif.html">mod_setenvif</a></code>
    and/or <code><a href="mod_rewrite.html">mod_rewrite</a></code> modules. For
    example, if you want to record requests for all GIF
    images on your server in a separate logfile but not in your main
    log, you can use:</p>
    
<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
    SetEnvIf Request_URI \.gif$ gif-image<br>
    CustomLog gif-requests.log common env=gif-image<br>
    CustomLog nongif-requests.log common env=!gif-image
</code></td></tr></table></blockquote>
<hr/><h2><a name="LogFormat">LogFormat</a> <a name="logformat">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: </strong></td><td>Describes a format for use in a log file</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:</a></td><td>LogFormat
    <em>format</em>|<em>nickname</em> [<em>nickname</em>]</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:</a></td><td>server config, virtual
host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:</a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:</a></td><td>mod_log_config</td></tr><tr><td nowrap="nowrap" align="left" valign="top"><a href="directive-dict.html#Compatibility" class="help">Compatibility:</a></td><td>Nickname only available in Apache 1.3 or later.
</td></tr></table></td></tr></table>
    <p>This directive specifies the format of the access log
    file.</p>

    <p>The <code class="directive">LogFormat</code> directive can take one of two
    forms. In the first form, where only one argument is specified,
    this directive sets the log format which will be used by logs
    specified in subsequent <code class="directive">TransferLog</code>
    directives. The single argument can specify an explicit
    <em>format</em> as discussed in <a href="#formats">custom log
    formats</a> section above. Alternatively, it can use a
    <em>nickname</em> to refer to a log format defined in a
    previous <code class="directive">LogFormat</code> directive as described
    below.</p>

    <p>The second form of the <code class="directive">LogFormat</code> 
    directive associates an explicit <em>format</em> with a
    <em>nickname</em>. This <em>nickname</em> can then be used in
    subsequent <code class="directive">LogFormat</code> or
    <code class="directive">CustomLog</code> directives rather than
    repeating the entire format string. A
    <code class="directive">LogFormat</code>
    directive which defines a nickname <strong>does nothing
    else</strong> -- that is, it <em>only</em> defines the
    nickname, it doesn't actually apply the format and make it the
    default. Therefore, it will not affect subsequent
    <code class="directive">TransferLog</code> directives.</p>

    <p>For example:</p>

    <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>LogFormat "%v %h %l %u %t \"%r\" %&gt;s %b"
    vhost_common</code></td></tr></table></blockquote>

<hr/><h2><a name="TransferLog">TransferLog</a> <a name="transferlog">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: </strong></td><td>Specifly location of a log file</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:</a></td><td>TransferLog <em>file</em>|<em>pipe</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:</a></td><td>server config, virtual
host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:</a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:</a></td><td>mod_log_config</td></tr><tr><td nowrap="nowrap" align="left" valign="top"><a href="directive-dict.html#Compatibility" class="help">Compatibility:</a></td><td/></tr></table></td></tr></table>

    <p>This directive has exactly the same arguments and effect as
    the <code class="directive">CustomLog</code> directive, with the
    exception that it does not allow the log format to be specified
    explicitly or for conditional logging of requests. Instead, the
    log format is determined by the most recently specified
    specified <code class="directive">LogFormat</code> directive (which
    does not define a nickname). Common Log Format is used if no
    other format has been specified.</p>

    <p>Example:</p>
<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
   LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-agent}i\""<br>
   TransferLog logs/access_log
</code></td></tr></table></blockquote>

<hr/></blockquote><h3 align="center">Apache HTTP Server Version 2.0</h3><a href="./"><img src="../images/index.gif" alt="Index"/></a><a href="../"><img src="../images/home.gif" alt="Home"/></a></body></html>