~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to docs/manual/mod/mod_log_config.html.en

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="ISO-8859-1"?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
3
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
 
4
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
5
              This file is generated from xml source: DO NOT EDIT
 
6
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
7
      -->
 
8
<title>mod_log_config - Apache HTTP Server</title>
 
9
<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
 
10
<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
 
11
<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
 
12
<link href="../images/favicon.ico" rel="shortcut icon" /></head>
 
13
<body>
 
14
<div id="page-header">
 
15
<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
 
16
<p class="apache">Apache HTTP Server Version 2.2</p>
 
17
<img alt="" src="../images/feather.gif" /></div>
 
18
<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
 
19
<div id="path">
 
20
<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.2</a> &gt; <a href="./">Modules</a></div>
 
21
<div id="page-content">
 
22
<div id="preamble"><h1>Apache Module mod_log_config</h1>
 
23
<div class="toplang">
 
24
<p><span>Available Languages: </span><a href="../en/mod/mod_log_config.html" title="English">&nbsp;en&nbsp;</a> |
 
25
<a href="../ja/mod/mod_log_config.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
 
26
<a href="../ko/mod/mod_log_config.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
 
27
</div>
 
28
<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Logging of the requests made to the server</td></tr>
 
29
<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
 
30
<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>log_config_module</td></tr>
 
31
<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_log_config.c</td></tr></table>
 
32
<h3>Summary</h3>
 
33
 
 
34
    <p>This module provides for flexible logging of client
 
35
    requests. Logs are written in a customizable format, and may be
 
36
    written directly to a file, or to an external program.
 
37
    Conditional logging is provided so that individual requests may
 
38
    be included or excluded from the logs based on characteristics
 
39
    of the request.</p>
 
40
 
 
41
    <p>Three directives are provided by this module:
 
42
    <code class="directive"><a href="#transferlog">TransferLog</a></code> to create
 
43
    a log file, <code class="directive"><a href="#logformat">LogFormat</a></code>
 
44
    to set a custom format, and <code class="directive"><a href="#customlog">CustomLog</a></code> to define a log file and format in one
 
45
    step. The <code class="directive">TransferLog</code> and <code class="directive">CustomLog</code> directives can be used multiple times in each
 
46
    server to cause each request to be logged to multiple files.</p>
 
47
</div>
 
48
<div id="quickview"><h3 class="directives">Directives</h3>
 
49
<ul id="toc">
 
50
<li><img alt="" src="../images/down.gif" /> <a href="#bufferedlogs">BufferedLogs</a></li>
 
51
<li><img alt="" src="../images/down.gif" /> <a href="#cookielog">CookieLog</a></li>
 
52
<li><img alt="" src="../images/down.gif" /> <a href="#customlog">CustomLog</a></li>
 
53
<li><img alt="" src="../images/down.gif" /> <a href="#logformat">LogFormat</a></li>
 
54
<li><img alt="" src="../images/down.gif" /> <a href="#transferlog">TransferLog</a></li>
 
55
</ul>
 
56
<h3>Topics</h3>
 
57
<ul id="topics">
 
58
<li><img alt="" src="../images/down.gif" /> <a href="#formats">Custom Log Formats</a></li>
 
59
<li><img alt="" src="../images/down.gif" /> <a href="#security">Security Considerations</a></li>
 
60
</ul><h3>See also</h3>
 
61
<ul class="seealso">
 
62
<li><a href="../logs.html">Apache Log Files</a></li>
 
63
</ul></div>
 
64
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
65
<div class="section">
 
66
<h2><a name="formats" id="formats">Custom Log Formats</a></h2>
 
67
 
 
68
    <p>The format argument to the <code class="directive"><a href="#logformat">LogFormat</a></code> and <code class="directive"><a href="#customlog">CustomLog</a></code> directives is a string. This string is
 
69
    used to log each request to the log file. It can contain literal
 
70
    characters copied into the log files and the C-style control
 
71
    characters "\n" and "\t" to represent new-lines and tabs.
 
72
    Literal quotes and back-slashes should be escaped with
 
73
    back-slashes.</p>
 
74
 
 
75
    <p>The characteristics of the request itself are logged by
 
76
    placing "<code>%</code>" directives in the format string, which are
 
77
    replaced in the log file by the values as follows:</p>
 
78
 
 
79
    <table class="bordered"><tr class="header"><th>Format&nbsp;String</th>
 
80
        <th>Description</th></tr>
 
81
<tr><td><code>%%</code></td>
 
82
        <td>The percent sign</td></tr>
 
83
<tr class="odd"><td><code>%a</code></td>
 
84
        <td>Remote IP-address</td></tr>
 
85
<tr><td><code>%A</code></td>
 
86
        <td>Local IP-address</td></tr>
 
87
<tr class="odd"><td><code>%B</code></td>
 
88
        <td>Size of response in bytes, excluding HTTP headers.</td></tr>
 
89
<tr><td><code>%b</code></td>
 
90
        <td>Size of response in bytes, excluding HTTP headers. In CLF format, <em>i.e.</em>
 
91
        a '<code>-</code>' rather than a 0 when no bytes are sent.</td></tr>
 
92
<tr class="odd"><td><code>%{<var>Foobar</var>}C</code></td>
 
93
        <td>The contents of cookie <var>Foobar</var> in the request sent
 
94
        to the server.</td></tr>
 
95
<tr><td><code>%D</code></td>
 
96
        <td>The time taken to serve the request, in microseconds.</td></tr>
 
97
<tr class="odd"><td><code>%{<var>FOOBAR</var>}e</code></td>
 
98
        <td>The contents of the environment variable
 
99
        <var>FOOBAR</var></td></tr>
 
100
<tr><td><code>%f</code></td>
 
101
        <td>Filename</td></tr>
 
102
<tr class="odd"><td><code>%h</code></td>
 
103
        <td>Remote host</td></tr>
 
104
<tr><td><code>%H</code></td>
 
105
        <td>The request protocol</td></tr>
 
106
<tr class="odd"><td><code>%{<var>Foobar</var>}i</code></td>
 
107
        <td>The contents of <code><var>Foobar</var>:</code> header line(s)
 
108
        in the request sent to the server.</td></tr>
 
109
<tr><td><code>%l</code></td>
 
110
        <td>Remote logname (from identd, if supplied). This will return a
 
111
        dash unless <code class="module"><a href="../mod/mod_ident.html">mod_ident</a></code> is present and <code class="directive"><a href="../mod/mod_ident.html#identitycheck">IdentityCheck</a></code> is set
 
112
        <code>On</code>.</td></tr>
 
113
<tr class="odd"><td><code>%m</code></td>
 
114
        <td>The request method</td></tr>
 
115
<tr><td><code>%{<var>Foobar</var>}n</code></td>
 
116
        <td>The contents of note <var>Foobar</var> from another
 
117
        module.</td></tr>
 
118
<tr class="odd"><td><code>%{<var>Foobar</var>}o</code></td>
 
119
        <td>The contents of <code><var>Foobar</var>:</code> header line(s)
 
120
        in the reply.</td></tr>
 
121
<tr><td><code>%p</code></td>
 
122
        <td>The canonical port of the server serving the request</td></tr>
 
123
<tr class="odd"><td><code>%P</code></td>
 
124
        <td>The process ID of the child that serviced the request.</td></tr>
 
125
<tr><td><code>%{<var>format</var>}P</code></td>
 
126
        <td>The process ID or thread id of the child that serviced the 
 
127
        request.  Valid formats are <code>pid</code>, <code>tid</code>,
 
128
        and <code>hextid</code>.  <code>hextid</code> requires APR 1.2.0 or 
 
129
        higher.
 
130
        </td></tr>
 
131
<tr class="odd"><td><code>%q</code></td>
 
132
        <td>The query string (prepended with a <code>?</code> if a query
 
133
        string exists, otherwise an empty string)</td></tr>
 
134
<tr><td><code>%r</code></td>
 
135
        <td>First line of request</td></tr>
 
136
<tr class="odd"><td><code>%s</code></td>
 
137
        <td>Status. For requests that got internally redirected, this is
 
138
        the status of the *original* request --- <code>%&gt;s</code>
 
139
        for the last.</td></tr>
 
140
<tr><td><code>%t</code></td>
 
141
        <td>Time the request was received (standard english
 
142
        format)</td></tr>
 
143
<tr class="odd"><td><code>%{<var>format</var>}t</code></td>
 
144
        <td>The time, in the form given by format, which should be in
 
145
        <code>strftime(3)</code> format. (potentially localized)</td></tr>
 
146
<tr><td><code>%T</code></td>
 
147
        <td>The time taken to serve the request, in seconds.</td></tr>
 
148
<tr class="odd"><td><code>%u</code></td>
 
149
        <td>Remote user (from auth; may be bogus if return status
 
150
        (<code>%s</code>) is 401)</td></tr>
 
151
<tr><td><code>%U</code></td>
 
152
        <td>The URL path requested, not including any query string.</td></tr>
 
153
<tr class="odd"><td><code>%v</code></td>
 
154
        <td>The canonical <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code>
 
155
        of the server serving the request.</td></tr>
 
156
<tr><td><code>%V</code></td>
 
157
        <td>The server name according to the <code class="directive"><a href="../mod/core.html#usecanonicalname">UseCanonicalName</a></code> setting.</td></tr>
 
158
<tr class="odd"><td><code>%X</code></td>
 
159
        <td>Connection status when response is completed:
 
160
 
 
161
        <table>
 
162
        
 
163
        <tr><td><code>X</code> =</td>
 
164
            <td>connection aborted before the response completed.</td></tr>
 
165
        <tr><td><code>+</code> =</td>
 
166
            <td>connection may be kept alive after the response is
 
167
            sent.</td></tr>
 
168
        <tr><td><code>-</code> = </td>
 
169
            <td>connection will be closed after the response is
 
170
            sent.</td></tr>
 
171
        </table>
 
172
 
 
173
        <p>(This directive was <code>%c</code> in late versions of Apache
 
174
        1.3, but this conflicted with the historical ssl
 
175
        <code>%{<var>var</var>}c</code> syntax.)</p></td></tr>
 
176
<tr><td><code>%I</code></td>
 
177
        <td>Bytes received, including request and headers, cannot be zero.
 
178
        You need to enable <code class="module"><a href="../mod/mod_logio.html">mod_logio</a></code> to use this.</td></tr>
 
179
<tr class="odd"><td><code>%O</code></td>
 
180
        <td>Bytes sent, including headers, cannot be zero. You need to
 
181
        enable <code class="module"><a href="../mod/mod_logio.html">mod_logio</a></code> to use this.</td></tr>
 
182
</table>
 
183
 
 
184
    <h3><a name="modifiers" id="modifiers">Modifiers</a></h3>
 
185
 
 
186
      <p>Particular items can be restricted to print only for
 
187
      responses with specific HTTP status codes by placing a
 
188
      comma-separated list of status codes immediately following the
 
189
      "%".  For example, <code>"%400,501{User-agent}i"</code> logs
 
190
      <code>User-agent</code> on 400 errors and 501 errors only.  For
 
191
      other status codes, the literal string <code>"-"</code> will be
 
192
      logged.  The status code list may be preceded by a
 
193
      "<code>!</code>" to indicate negation:
 
194
      <code>"%!200,304,302{Referer}i"</code> logs <code>Referer</code>
 
195
      on all requests that do <em>not</em> return one of the three
 
196
      specified codes.</p>
 
197
 
 
198
      <p>The modifiers "&lt;" and "&gt;" can be used for requests that
 
199
      have been internally redirected to choose whether the original
 
200
      or final (respectively) request should be consulted.  By
 
201
      default, the <code>%</code> directives <code>%s, %U, %T,
 
202
      %D,</code> and <code>%r</code> look at the original request
 
203
      while all others look at the final request.  So for example,
 
204
      <code>%&gt;s</code> can be used to record the final status of
 
205
      the request and <code>%&lt;u</code> can be used to record the
 
206
      original authenticated user on a request that is internally
 
207
      redirected to an unauthenticated resource.</p>
 
208
 
 
209
    
 
210
 
 
211
    <h3><a name="format-notes" id="format-notes">Some Notes</a></h3>
 
212
 
 
213
      <p>For security reasons, starting with version 2.0.46,
 
214
      non-printable and other special characters in <code>%r</code>,
 
215
      <code>%i</code> and <code>%o</code> are escaped using
 
216
      <code>\x<var>hh</var></code> sequences, where <var>hh</var>
 
217
      stands for the hexadecimal representation of the raw
 
218
      byte. Exceptions from this rule are <code>"</code> and
 
219
      <code>\</code>, which are escaped by prepending a backslash, and
 
220
      all whitespace characters, which are written in their C-style
 
221
      notation (<code>\n</code>, <code>\t</code>, etc).  In versions
 
222
      prior to 2.0.46, no escaping was performed on these strings so
 
223
      you had to be quite careful when dealing with raw log files.</p>
 
224
 
 
225
      <p>In httpd 2.0, unlike 1.3, the <code>%b</code> and
 
226
      <code>%B</code> format strings do not represent the number of
 
227
      bytes sent to the client, but simply the size in bytes of the
 
228
      HTTP response (which will differ, for instance, if the
 
229
      connection is aborted, or if SSL is used).  The <code>%O</code>
 
230
      format provided by <code class="module"><a href="../mod/mod_logio.html">mod_logio</a></code> will log the
 
231
      actual number of bytes sent over the network.</p>
 
232
 
 
233
    
 
234
 
 
235
    <h3><a name="examples" id="examples">Examples</a></h3>
 
236
 
 
237
      <p>Some commonly used log format strings are:</p>
 
238
 
 
239
      <dl>
 
240
        <dt>Common Log Format (CLF)</dt>
 
241
        <dd><code>"%h %l %u %t \"%r\" %&gt;s %b"</code></dd>
 
242
 
 
243
        <dt>Common Log Format with Virtual Host</dt>
 
244
        <dd><code>"%v %h %l %u %t \"%r\" %&gt;s %b"</code></dd>
 
245
 
 
246
        <dt>NCSA extended/combined log format</dt>
 
247
        <dd><code>"%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\"
 
248
        \"%{User-agent}i\""</code></dd>
 
249
 
 
250
        <dt>Referer log format</dt>
 
251
        <dd><code>"%{Referer}i -&gt; %U"</code></dd>
 
252
 
 
253
        <dt>Agent (Browser) log format</dt>
 
254
        <dd><code>"%{User-agent}i"</code></dd>
 
255
      </dl>
 
256
    
 
257
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
258
<div class="section">
 
259
<h2><a name="security" id="security">Security Considerations</a></h2>
 
260
    <p>See the <a href="../misc/security_tips.html#serverroot">security tips</a>
 
261
    document for details on why your security could be compromised
 
262
    if the directory where logfiles are stored is writable by
 
263
    anyone other than the user that starts the server.</p>
 
264
</div>
 
265
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
266
<div class="directive-section"><h2><a name="BufferedLogs" id="BufferedLogs">BufferedLogs</a> <a name="bufferedlogs" id="bufferedlogs">Directive</a></h2>
 
267
<table class="directive">
 
268
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Buffer log entries in memory before writing to disk</td></tr>
 
269
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>BufferedLogs On|Off</code></td></tr>
 
270
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>BufferedLogs Off</code></td></tr>
 
271
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
 
272
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
 
273
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr>
 
274
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in versions 2.0.41 and later.</td></tr>
 
275
</table>
 
276
    <p>The <code class="directive">BufferedLogs</code> directive causes
 
277
    <code class="module"><a href="../mod/mod_log_config.html">mod_log_config</a></code> to store several log entries in
 
278
    memory and write them together to disk, rather than writing them
 
279
    after each request.  On some systems, this may result in more
 
280
    efficient disk access and hence higher performance.  It may be
 
281
    set only once for the entire server; it cannot be configured
 
282
    per virtual-host.</p>
 
283
 
 
284
    <div class="note">This directive is experimental and should be used with
 
285
    caution.</div>
 
286
 
 
287
</div>
 
288
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
289
<div class="directive-section"><h2><a name="CookieLog" id="CookieLog">CookieLog</a> <a name="cookielog" id="cookielog">Directive</a></h2>
 
290
<table class="directive">
 
291
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets filename for the logging of cookies</td></tr>
 
292
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CookieLog <var>filename</var></code></td></tr>
 
293
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
 
294
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
 
295
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr>
 
296
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>This directive is deprecated.</td></tr>
 
297
</table>
 
298
    <p>The <code class="directive">CookieLog</code> directive sets the 
 
299
    filename for logging of cookies. The filename is relative to the
 
300
    <code class="directive"><a href="../mod/core.html#serverroot">ServerRoot</a></code>. This directive is
 
301
    included only for compatibility with <code>mod_cookies</code>,
 
302
    and is deprecated.</p>
 
303
 
 
304
</div>
 
305
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
306
<div class="directive-section"><h2><a name="CustomLog" id="CustomLog">CustomLog</a> <a name="customlog" id="customlog">Directive</a></h2>
 
307
<table class="directive">
 
308
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets filename and format of log file</td></tr>
 
309
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CustomLog  <var>file</var>|<var>pipe</var>
 
310
<var>format</var>|<var>nickname</var>
 
311
[env=[!]<var>environment-variable</var>]</code></td></tr>
 
312
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
 
313
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
 
314
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr>
 
315
</table>
 
316
    <p>The <code class="directive">CustomLog</code> directive is used to
 
317
    log requests to the server. A log format is specified, and the
 
318
    logging can optionally be made conditional on request
 
319
    characteristics using environment variables.</p>
 
320
 
 
321
    <p>The first argument, which specifies the location to which
 
322
    the logs will be written, can take one of the following two
 
323
    types of values:</p>
 
324
 
 
325
    <dl>
 
326
      <dt><var>file</var></dt>
 
327
      <dd>A filename, relative to the <code class="directive"><a href="../mod/core.html#serverroot">ServerRoot</a></code>.</dd>
 
328
 
 
329
      <dt><var>pipe</var></dt>
 
330
      <dd>The pipe character "<code>|</code>", followed by the path
 
331
      to a program to receive the log information on its standard
 
332
      input.
 
333
 
 
334
      <div class="warning"><h3>Security:</h3>
 
335
      <p>If a program is used, then it will be run as the user who
 
336
      started <code class="program"><a href="../programs/httpd.html">httpd</a></code>. This will be root if the server was
 
337
      started by root; be sure that the program is secure.</p>
 
338
      </div>
 
339
      <div class="warning"><h3>Note</h3>
 
340
        <p>When entering a file path on non-Unix platforms, care should be taken
 
341
        to make sure that only forward slashed are used even though the platform
 
342
        may allow the use of back slashes. In general it is a good idea to always 
 
343
        use forward slashes throughout the configuration files.</p>
 
344
      </div></dd>
 
345
    </dl>
 
346
 
 
347
    <p>The second argument specifies what will be written to the
 
348
    log file. It can specify either a <var>nickname</var> defined by
 
349
    a previous <code class="directive"><a href="#logformat">LogFormat</a></code>
 
350
    directive, or it can be an explicit <var>format</var> string as
 
351
    described in the <a href="#formats">log formats</a> section.</p>
 
352
 
 
353
    <p>For example, the following two sets of directives have
 
354
    exactly the same effect:</p>
 
355
 
 
356
    <div class="example"><p><code>
 
357
      # CustomLog with format nickname<br />
 
358
      LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common<br />
 
359
      CustomLog logs/access_log common<br />
 
360
      <br />
 
361
      # CustomLog with explicit format string<br />
 
362
      CustomLog logs/access_log "%h %l %u %t \"%r\" %&gt;s %b"
 
363
    </code></p></div>
 
364
 
 
365
    <p>The third argument is optional and controls whether or
 
366
    not to log a particular request based on the
 
367
    presence or absence of a particular variable in the server
 
368
    environment. If the specified <a href="../env.html">environment
 
369
    variable</a> is set for the request (or is not set, in the case
 
370
    of a '<code>env=!<var>name</var></code>' clause), then the
 
371
    request will be logged.</p>
 
372
 
 
373
    <p>Environment variables can be set on a per-request
 
374
    basis using the <code class="module"><a href="../mod/mod_setenvif.html">mod_setenvif</a></code>
 
375
    and/or <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> modules. For
 
376
    example, if you want to record requests for all GIF
 
377
    images on your server in a separate logfile but not in your main
 
378
    log, you can use:</p>
 
379
    
 
380
    <div class="example"><p><code>
 
381
      SetEnvIf Request_URI \.gif$ gif-image<br />
 
382
      CustomLog gif-requests.log common env=gif-image<br />
 
383
      CustomLog nongif-requests.log common env=!gif-image
 
384
    </code></p></div>
 
385
 
 
386
    <p>Or, to reproduce the behavior of the old RefererIgnore
 
387
    directive, you might use the following:</p>
 
388
 
 
389
    <div class="example"><p><code>
 
390
    SetEnvIf Referer example\.com localreferer<br />
 
391
    CustomLog referer.log referer env=!localreferer
 
392
    </code></p></div>
 
393
 
 
394
</div>
 
395
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
396
<div class="directive-section"><h2><a name="LogFormat" id="LogFormat">LogFormat</a> <a name="logformat" id="logformat">Directive</a></h2>
 
397
<table class="directive">
 
398
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Describes a format for use in a log file</td></tr>
 
399
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LogFormat <var>format</var>|<var>nickname</var>
 
400
[<var>nickname</var>]</code></td></tr>
 
401
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>LogFormat "%h %l %u %t \"%r\" %&gt;s %b"</code></td></tr>
 
402
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
 
403
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
 
404
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr>
 
405
</table>
 
406
    <p>This directive specifies the format of the access log
 
407
    file.</p>
 
408
 
 
409
    <p>The <code class="directive">LogFormat</code> directive can take one of two
 
410
    forms. In the first form, where only one argument is specified,
 
411
    this directive sets the log format which will be used by logs
 
412
    specified in subsequent <code class="directive">TransferLog</code>
 
413
    directives. The single argument can specify an explicit
 
414
    <var>format</var> as discussed in the <a href="#formats">custom log
 
415
    formats</a> section above. Alternatively, it can use a
 
416
    <var>nickname</var> to refer to a log format defined in a
 
417
    previous <code class="directive">LogFormat</code> directive as described
 
418
    below.</p>
 
419
 
 
420
    <p>The second form of the <code class="directive">LogFormat</code> 
 
421
    directive associates an explicit <var>format</var> with a
 
422
    <var>nickname</var>. This <var>nickname</var> can then be used in
 
423
    subsequent <code class="directive">LogFormat</code> or
 
424
    <code class="directive"><a href="#customlog">CustomLog</a></code> directives
 
425
    rather than repeating the entire format string. A
 
426
    <code class="directive">LogFormat</code> directive that defines a nickname
 
427
    <strong>does nothing else</strong> -- that is, it <em>only</em>
 
428
    defines the nickname, it doesn't actually apply the format and make
 
429
    it the default. Therefore, it will not affect subsequent
 
430
    <code class="directive"><a href="#transferlog">TransferLog</a></code> directives.
 
431
    In addition, <code class="directive">LogFormat</code> cannot use one nickname
 
432
    to define another nickname. Note that the nickname should not contain
 
433
    percent signs (<code>%</code>).</p>
 
434
 
 
435
    <div class="example"><h3>Example</h3><p><code>
 
436
      LogFormat "%v %h %l %u %t \"%r\" %&gt;s %b" vhost_common
 
437
    </code></p></div>
 
438
 
 
439
</div>
 
440
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 
441
<div class="directive-section"><h2><a name="TransferLog" id="TransferLog">TransferLog</a> <a name="transferlog" id="transferlog">Directive</a></h2>
 
442
<table class="directive">
 
443
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Specify location of a log file</td></tr>
 
444
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>TransferLog <var>file</var>|<var>pipe</var></code></td></tr>
 
445
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
 
446
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
 
447
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr>
 
448
</table>
 
449
    <p>This directive has exactly the same arguments and effect as
 
450
    the <code class="directive"><a href="#customlog">CustomLog</a></code>
 
451
    directive, with the exception that it does not allow the log format
 
452
    to be specified explicitly or for conditional logging of requests.
 
453
    Instead, the log format is determined by the most recently specified
 
454
    <code class="directive"><a href="#logformat">LogFormat</a></code> directive
 
455
    which does not define a nickname. Common Log Format is used if no
 
456
    other format has been specified.</p>
 
457
 
 
458
    <div class="example"><h3>Example</h3><p><code>
 
459
      LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-agent}i\""<br />
 
460
      TransferLog logs/access_log
 
461
    </code></p></div>
 
462
 
 
463
</div>
 
464
</div>
 
465
<div class="bottomlang">
 
466
<p><span>Available Languages: </span><a href="../en/mod/mod_log_config.html" title="English">&nbsp;en&nbsp;</a> |
 
467
<a href="../ja/mod/mod_log_config.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
 
468
<a href="../ko/mod/mod_log_config.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
 
469
</div><div id="footer">
 
470
<p class="apache">Copyright 2006 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
 
471
<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
 
472
</body></html>
 
 
b'\\ No newline at end of file'