summaryrefslogtreecommitdiffstats
path: root/docs/manual/mod/mod_log_config.html.en.utf8
blob: e30a100cb38ed808b29ceb739e6b5ecce647e363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<!--
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
              This file is generated from xml source: DO NOT EDIT
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      -->
<title>mod_log_config - Apache HTTP Server Version 2.5</title>
<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
<script src="../style/scripts/prettify.min.js" type="text/javascript">
</script>

<link href="../images/favicon.ico" rel="shortcut icon" /></head>
<body>
<div id="page-header">
<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
<p class="apache">Apache HTTP Server Version 2.5</p>
<img alt="" src="../images/feather.png" /></div>
<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
<div id="path">
<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.5</a> &gt; <a href="./">Modules</a></div>
<div id="page-content">
<div id="preamble"><h1>Apache Module mod_log_config</h1>
<div class="toplang">
<p><span>Available Languages: </span><a href="../en/mod/mod_log_config.html" title="English">&nbsp;en&nbsp;</a> |
<a href="../fr/mod/mod_log_config.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
<a href="../ja/mod/mod_log_config.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="../ko/mod/mod_log_config.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="../tr/mod/mod_log_config.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
</div>
<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>
<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
<tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>log_config_module</td></tr>
<tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_log_config.c</td></tr></table>
<h3>Summary</h3>

    <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 class="directive"><a href="#transferlog">TransferLog</a></code> to create
    a log file, <code class="directive"><a href="#logformat">LogFormat</a></code>
    to set a custom format, and <code class="directive"><a href="#customlog">CustomLog</a></code> to define a log file and format in one
    step. The <code class="directive">TransferLog</code> and <code class="directive">CustomLog</code> directives can be used multiple times in each
    server to cause each request to be logged to multiple files.</p>
</div>
<div id="quickview"><h3>Topics</h3>
<ul id="topics">
<li><img alt="" src="../images/down.gif" /> <a href="#formats">Custom Log Formats</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#security">Security Considerations</a></li>
</ul><h3 class="directives">Directives</h3>
<ul id="toc">
<li><img alt="" src="../images/down.gif" /> <a href="#bufferedlogs">BufferedLogs</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#customlog">CustomLog</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#globallog">GlobalLog</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#logformat">LogFormat</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#transferlog">TransferLog</a></li>
</ul>
<h3>Bugfix checklist</h3><ul class="seealso"><li><a href="https://www.apache.org/dist/httpd/CHANGES_2.4">httpd changelog</a></li><li><a href="https://bz.apache.org/bugzilla/buglist.cgi?bug_status=__open__&amp;list_id=144532&amp;product=Apache%20httpd-2&amp;query_format=specific&amp;order=changeddate%20DESC%2Cpriority%2Cbug_severity&amp;component=mod_log_config">Known issues</a></li><li><a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2&amp;component=mod_log_config">Report a bug</a></li></ul><h3>See also</h3>
<ul class="seealso">
<li><a href="../logs.html">Apache Log Files</a></li>
<li><a href="#comments_section">Comments</a></li></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="formats" id="formats">Custom Log Formats</a> <a title="Permanent link" href="#formats" class="permalink">&para;</a></h2>

    <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
    used to log each request to the log file. It can contain literal
    characters copied into the log files and the C-style control
    characters "\n" and "\t" to represent new-lines and tabs.
    Literal quotes and backslashes should be escaped with
    backslashes.</p>

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

    <table class="bordered"><tr class="header"><th>Format&nbsp;String</th>
        <th>Description</th></tr>
<tr><td><code>%%</code></td>
        <td>The percent sign.</td></tr>
<tr class="odd"><td><code>%a</code></td>
        <td>Client IP address of the request (see the
        <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code> module).</td></tr>
<tr><td><code>%{c}a</code></td>
        <td>Underlying peer IP address of the connection (see the
        <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code> module).</td></tr>
<tr class="odd"><td><code>%A</code></td>
        <td>Local IP-address.</td></tr>
<tr><td><code>%B</code></td>
        <td>Size of response in bytes, excluding HTTP headers.</td></tr>
<tr class="odd"><td><code>%b</code></td>
        <td>Size of response in bytes, excluding HTTP headers. In CLF format, <em>i.e.</em>
        a '<code>-</code>' rather than a 0 when no bytes are sent.</td></tr>
<tr><td><code>%{<var>VARNAME</var>}C</code></td>
        <td>The contents of cookie <var>VARNAME</var> in the request sent
        to the server. Only version 0 cookies are fully supported.</td></tr>
<tr class="odd"><td><code>%D</code></td>
        <td>The time taken to serve the request, in microseconds. See %T for details.</td></tr>
<tr><td><code>%{<var>VARNAME</var>}e</code></td>
        <td>The contents of the environment variable
        <var>VARNAME</var>.</td></tr>
<tr class="odd"><td><code>%f</code></td>
        <td>Filename.</td></tr>
<tr><td><code>%h</code></td>
        <td>Remote hostname. Will log the IP address if <code class="directive"><a href="../mod/core.html#hostnamelookups">HostnameLookups</a></code> is set to
        <code>Off</code>, which is the default. If it logs the hostname
        for only a few hosts, you probably have access control
        directives mentioning them by name. See <a href="mod_authz_host.html#reqhost">the Require host
        documentation</a>. This format is affected by modifications to the 
        remote hostname by modules like <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code>.</td></tr>
<tr class="odd"><td><code>%{c}h</code></td>
        <td>Like <code>%h</code>, but always reports on the hostname of the
        underlying TCP connection and not any modifications to the 
        remote hostname by modules like <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code>.</td></tr>
<tr><td><code>%H</code></td>
        <td>The request protocol.</td></tr>
<tr class="odd"><td><code>%{<var>VARNAME</var>}i</code></td>
        <td>The contents of <code><var>VARNAME</var>:</code> header line(s)
        in the request sent to the server. Changes made by other
        modules (e.g. <code class="module"><a href="../mod/mod_headers.html">mod_headers</a></code>) affect this.  If you're
        interested in what the request header was prior to when most
        modules would have modified it, use <code class="module"><a href="../mod/mod_setenvif.html">mod_setenvif</a></code>
        to copy the header into an internal environment variable and log
        that value with the <code>%{<var>VARNAME</var>}e</code> described
        above.
        </td></tr>
<tr><td><code>%k</code></td>
        <td>Number of keepalive requests handled on this connection.  Interesting if
          <code class="directive"><a href="../mod/core.html#keepalive">KeepAlive</a></code> is being used, so that,
          for example, a '1' means the first keepalive request after the initial
          one, '2' the second, etc...;
          otherwise this is always 0 (indicating the initial request).</td></tr>
<tr class="odd"><td><code>%l</code></td>
        <td>Remote logname (from identd, if supplied). This will return a
        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
        <code>On</code>.</td></tr>
<tr><td><code>%L</code></td>
        <td>The request log ID from the error log (or '-' if nothing has been
            logged to the error log for this request). Look for the
            matching error log line to see what request caused what error.</td></tr>
<tr class="odd"><td><code>%{c}L</code></td>
        <td>The connection log ID from the error log (or '-' if nothing has been
            logged to the error log for this request). Look for the
            matching error log line to see what request caused what error.</td></tr>
<tr><td><code>%m</code></td>
        <td>The request method.</td></tr>
<tr class="odd"><td><code>%{<var>VARNAME</var>}n</code></td>
        <td>The contents of note <var>VARNAME</var> from another
        module.</td></tr>
<tr><td><code>%{<var>VARNAME</var>}o</code></td>
        <td>The contents of <code><var>VARNAME</var>:</code> header line(s)
        in the reply.</td></tr>
<tr class="odd"><td><code>%p</code></td>
        <td>The canonical port of the server serving the request.</td></tr>
<tr><td><code>%{<var>format</var>}p</code></td>
        <td>The canonical port of the server serving the request, or the
        server's actual port, or the client's actual port. Valid formats
        are <code>canonical</code>, <code>local</code>, or <code>remote</code>.
        </td></tr>
<tr class="odd"><td><code>%P</code></td>
        <td>The process ID of the child that serviced the request.</td></tr>
<tr><td><code>%{<var>format</var>}P</code></td>
        <td>The process ID or thread ID of the child that serviced the
        request.  Valid formats are <code>pid</code>, <code>tid</code>,
        and <code>hextid</code>.
        </td></tr>
<tr class="odd"><td><code>%q</code></td>
        <td>The query string (prepended with a <code>?</code> if a query
        string exists, otherwise an empty string).</td></tr>
<tr><td><code>%r</code></td>
        <td>First line of request.</td></tr>
<tr class="odd"><td><code>%R</code></td>
        <td>The handler generating the response (if any).</td></tr>
<tr><td><code>%s</code></td>
        <td>Status. For requests that have been internally redirected, this is
        the status of the <em>original</em> request. Use <code>%&gt;s</code>
        for the final status.</td></tr>
<tr class="odd"><td><code>%t</code></td>
        <td>Time the request was received, in the format <code>[18/Sep/2011:19:18:28 -0400]</code>.
        The last number indicates the timezone offset from GMT</td></tr>
<tr><td><code>%{<var>format</var>}t</code></td>
        <td>The time, in the form given by format, which should be in
        an extended <code>strftime(3)</code> format (potentially localized).
        If the format starts with <code>begin:</code> (default) the time is taken
        at the beginning of the request processing. If it starts with
        <code>end:</code> it is the time when the log entry gets written,
        close to the end of the request processing. In addition to the formats
        supported by <code>strftime(3)</code>, the following format tokens are
        supported:
        <table>
        <tr><td><code>sec</code></td><td>number of seconds since the Epoch</td></tr>
        <tr><td><code>msec</code></td><td>number of milliseconds since the Epoch</td></tr>
        <tr><td><code>usec</code></td><td>number of microseconds since the Epoch</td></tr>
        <tr><td><code>msec_frac</code></td><td>millisecond fraction</td></tr>
        <tr><td><code>usec_frac</code></td><td>microsecond fraction</td></tr>
        </table>
        These tokens can not be combined with each other or <code>strftime(3)</code>
        formatting in the same format string. You can use multiple
        <code>%{<var>format</var>}t</code> tokens instead.
        </td></tr>
<tr class="odd"><td><code>%T</code></td>
        <td><p>The time taken to serve the request, in seconds. The time measured
        begins when the first line of the HTTP request is read from the host
        operating system by the HTTP server and ends when the last byte of
        the response is written by the HTTP server to the host operating system.</p>
        <p>The time measured does <em>not</em> include any of the following:</p>
        <ul>
         <li> Time spent in TCP or TLS handshakes.</li>
         <li> The time before a webserver thread is able to read the first 
              line of the request.</li>
         <li> Delays in the operating system putting the response data out 
              onto the network.</li>
         <li> Time taken for the response to arrive at the client host.</li>
         <li> Time taken for the the useragent to read and process the 
              response.</li>
       </ul>
    </td></tr>
<tr><td><code>%{<var>UNIT</var>}T</code></td>
        <td>The time taken to serve the request, in a time unit given by
        <code>UNIT</code>. Valid units are <code>ms</code> for milliseconds,
        <code>us</code> for microseconds, and <code>s</code> for seconds.
        Using <code>s</code> gives the same result as <code>%T</code>
        without any format; using <code>us</code> gives the same result
        as <code>%D</code>. Combining <code>%T</code> with a unit is
        available in 2.4.13 and later.</td></tr>
<tr class="odd"><td><code>%u</code></td>
        <td>Remote user if the request was authenticated. May be bogus if return status
        (<code>%s</code>) is 401 (unauthorized).</td></tr>
<tr><td><code>%U</code></td>
        <td>The URL path requested, not including any query string.</td></tr>
<tr class="odd"><td><code>%v</code></td>
        <td>The canonical <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code>
        of the server serving the request.</td></tr>
<tr><td><code>%V</code></td>
        <td>The server name according to the <code class="directive"><a href="../mod/core.html#usecanonicalname">UseCanonicalName</a></code> setting.</td></tr>
<tr class="odd"><td><code>%X</code></td>
        <td>Connection status when response is completed:

        <table>
        
        <tr><td><code>X</code> =</td>
            <td>Connection aborted before the response completed.</td></tr>
        <tr><td><code>+</code> =</td>
            <td>Connection may be kept alive after the response is
            sent.</td></tr>
        <tr><td><code>-</code> = </td>
            <td>Connection will be closed after the response is
            sent.</td></tr>
        </table>

        </td></tr>
<tr><td><code>%I</code></td>
        <td>Bytes received, including request and headers. Cannot be zero.
        You need to enable <code class="module"><a href="../mod/mod_logio.html">mod_logio</a></code> to use this.</td></tr>
<tr class="odd"><td><code>%O</code></td>
        <td>Bytes sent, including headers. May be zero in rare cases
        such as when a request is aborted before a response is sent.
        You need to enable <code class="module"><a href="../mod/mod_logio.html">mod_logio</a></code> to use this.</td></tr>
<tr><td><code>%S</code></td>
        <td>Bytes transferred (received and sent), including request and headers,
        cannot be zero. This is the combination of %I and %O. You need to
        enable <code class="module"><a href="../mod/mod_logio.html">mod_logio</a></code> to use this.</td></tr>
<tr class="odd"><td><code>%{<var>VARNAME</var>}^ti</code></td>
        <td>The contents of <code><var>VARNAME</var>:</code> trailer line(s)
        in the request sent to the server.  </td></tr>
<tr><td><code>%{<var>VARNAME</var>}^to</code></td>
        <td>The contents of <code><var>VARNAME</var>:</code> trailer line(s)
        in the response sent from the server.  </td></tr>
</table>

    <h3><a name="modifiers" id="modifiers">Modifiers</a></h3>

      <p>Particular items can be restricted to print only for
      responses with specific HTTP status codes by placing a
      comma-separated list of status codes immediately following the
      "%". The status code list may be preceded by a "<code>!</code>" to
      indicate negation.</p>

    <table class="bordered"><tr class="header"><th>Format String</th>
    <th>Meaning</th></tr>
<tr>
    <td><code>%400,501{User-agent}i</code></td>
    <td>Logs <code>User-agent</code> on 400 errors and 501 errors only. For
      other status codes, the literal string <code>"-"</code> will be
      logged.</td></tr>
<tr class="odd"><td><code>%!200,304,302{Referer}i</code></td>
    <td>Logs <code>Referer</code> on all requests that do
    <em>not</em> return one of the three specified codes,
    "<code>-</code>" otherwise.
    </td></tr>
</table>

      <p>The modifiers "&lt;" and "&gt;" can be used for requests that
      have been internally redirected to choose whether the original
      or final (respectively) request should be consulted.  By
      default, the <code>%</code> directives <code>%s, %U, %T,
      %D,</code> and <code>%r</code> look at the original request
      while all others look at the final request.  So for example,
      <code>%&gt;s</code> can be used to record the final status of
      the request and <code>%&lt;u</code> can be used to record the
      original authenticated user on a request that is internally
      redirected to an unauthenticated resource.</p>

    

    <h3><a name="format-notes" id="format-notes">Format Notes</a></h3>

      <p>For security reasons, starting with version 2.0.46,
      non-printable and other special characters in <code>%r</code>,
      <code>%i</code> and <code>%o</code> are escaped using
      <code>\x<var>hh</var></code> sequences, where <var>hh</var>
      stands for the hexadecimal representation of the raw
      byte. Exceptions from this rule are <code>"</code> and
      <code>\</code>, which are escaped by prepending a backslash, and
      all whitespace characters, which are written in their C-style
      notation (<code>\n</code>, <code>\t</code>, etc).  In versions
      prior to 2.0.46, no escaping was performed on these strings so
      you had to be quite careful when dealing with raw log files.</p>

      <p>Since httpd 2.0, unlike 1.3, the <code>%b</code> and
      <code>%B</code> format strings do not represent the number of
      bytes sent to the client, but simply the size in bytes of the
      HTTP response (which will differ, for instance, if the
      connection is aborted, or if SSL is used).  The <code>%O</code>
      format provided by <code class="module"><a href="../mod/mod_logio.html">mod_logio</a></code> will log the
      actual number of bytes sent over the network.</p>

      <div class="note">
      <p>Note: <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> is implemented as a
      quick-handler and not as a standard handler. Therefore, the
      <code>%R</code> format string will not return any handler
      information when content caching is involved.</p>
      </div>

      <div class="note">
      <p>Note: The '^' character at the start of three-character formats
      has no significance, but it must be the first character of any newly
      added three-character format to avoid potential conflicts with log
      formats that use literals adjacent to a format specifier, such as
      "%Dus".</p>
      </div>

    

    <h3><a name="examples" id="examples">Examples</a></h3>

      <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>You can use the <code>%{format}t</code> directive multiple
      times to build up a time format using the extended format tokens
      like <code>msec_frac</code>:</p>
      <dl>
<dt>Timestamp including milliseconds</dt>
<dd><code>"%{%d/%b/%Y %T}t.%{msec_frac}t %{%z}t"</code></dd>

      </dl>

    
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="security" id="security">Security Considerations</a> <a title="Permanent link" href="#security" class="permalink">&para;</a></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>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="BufferedLogs" id="BufferedLogs">BufferedLogs</a> <a name="bufferedlogs" id="bufferedlogs">Directive</a> <a title="Permanent link" href="#bufferedlogs" class="permalink">&para;</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Buffer log entries in memory before writing to disk</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>BufferedLogs On|Off</code></td></tr>
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>BufferedLogs Off</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr>
</table>
    <p>The <code class="directive">BufferedLogs</code> directive causes
    <code class="module"><a href="../mod/mod_log_config.html">mod_log_config</a></code> to store several log entries in
    memory and write them together to disk, rather than writing them
    after each request.  On some systems, this may result in more
    efficient disk access and hence higher performance.  It may be
    set only once for the entire server; it cannot be configured
    per virtual-host.</p>

    <div class="note">This directive should be used with caution as a crash might
    cause loss of logging data.</div>

</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="CustomLog" id="CustomLog">CustomLog</a> <a name="customlog" id="customlog">Directive</a> <a title="Permanent link" href="#customlog" class="permalink">&para;</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets filename and format of log file</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CustomLog  <var>file</var>|<var>pipe</var>|<var>provider</var>
<var>format</var>|<var>nickname</var>
[env=[!]<var>environment-variable</var>|
expr=<var>expression</var>]</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</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 one of the following two
    types of values:</p>

    <dl>
      <dt><var>file</var></dt>
      <dd>A filename, relative to the <code class="directive"><a href="../mod/core.html#serverroot">ServerRoot</a></code>.</dd>

      <dt><var>pipe</var></dt>
      <dd>The pipe character "<code>|</code>", followed by the path
      to a program to receive the log information on its standard
      input. See the notes on <a href="../logs.html#piped">piped logs</a>
      for more information.

      <div class="warning"><h3>Security:</h3>
      <p>If a program is used, then it will be run as the user who
      started <code class="program"><a href="../programs/httpd.html">httpd</a></code>. This will be root if the server was
      started by root; be sure that the program is secure.</p>
      </div>
      <div class="warning"><h3>Note</h3>
        <p>When entering a file path on non-Unix platforms, care should be taken
        to make sure that only forward slashed are used even though the platform
        may allow the use of back slashes. In general it is a good idea to always
        use forward slashes throughout the configuration files.</p>
      </div></dd>
      <dt><var>provider</var></dt>
      <dd>Modules implementing ErrorLog providers can also be used as a target
      for CustomLog messages. To use ErrorLog provider as a target,
      "provider:argument" syntax must be used. You can for example use
      <code class="module"><a href="../mod/mod_journald.html">mod_journald</a></code> or <code class="module"><a href="../mod/mod_syslog.html">mod_syslog</a></code>
      as a provider:
    <pre class="prettyprint lang-config"># CustomLog logging to journald
CustomLog "journald" "%h %l %u %t \"%r\" %&gt;s %b"

# CustomLog logging to syslog with "user" facility
CustomLog "syslog:user" "%h %l %u %t \"%r\" %&gt;s %b"</pre>

      </dd>
    </dl>

    <p>The second argument specifies what will be written to the
    log file. It can specify either a <var>nickname</var> defined by
    a previous <code class="directive"><a href="#logformat">LogFormat</a></code>
    directive, or it can be an explicit <var>format</var> 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>

    <pre class="prettyprint lang-config"># CustomLog with format nickname
LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common
CustomLog "logs/access_log" common

# CustomLog with explicit format string
CustomLog "logs/access_log" "%h %l %u %t \"%r\" %&gt;s %b"</pre>


    <p>The third argument is optional and controls whether or
    not to log a particular request. The condition can be the
    presence or absence (in the case of a '<code>env=!<var>name</var></code>'
    clause) of a particular variable in the server
    <a href="../env.html">environment</a>. Alternatively, the condition
    can be expressed as arbitrary boolean <a href="../expr.html">expression</a>. If the condition is not satisfied, the request
    will not be logged. References to HTTP headers  in the expression
    will not cause the header names to be added to the Vary header.</p>

    <p>Environment variables can be set on a per-request
    basis using the <code class="module"><a href="../mod/mod_setenvif.html">mod_setenvif</a></code>
    and/or <code class="module"><a href="../mod/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>

    <pre class="prettyprint lang-config">SetEnvIf Request_URI \.gif$ gif-image
CustomLog "gif-requests.log" common env=gif-image
CustomLog "nongif-requests.log" common env=!gif-image</pre>


    <p>Or, to reproduce the behavior of the old RefererIgnore
    directive, you might use the following:</p>

    <pre class="prettyprint lang-config">SetEnvIf Referer example\.com localreferer
CustomLog "referer.log" referer env=!localreferer</pre>


</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="GlobalLog" id="GlobalLog">GlobalLog</a> <a name="globallog" id="globallog">Directive</a> <a title="Permanent link" href="#globallog" class="permalink">&para;</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets filename and format of log file</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>GlobalLog  <var>file</var>|<var>pipe</var>|<var>provider</var>
<var>format</var>|<var>nickname</var>
[env=[!]<var>environment-variable</var>|
expr=<var>expression</var>]</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache HTTP Server 2.4.19 and later</td></tr>
</table>

    <p>The <code class="directive">GlobalLog</code> directive defines a log shared
       by the main server configuration and all defined virtual hosts.</p>

    <p>The <code class="directive">GlobalLog</code> directive is identical to
    the <code class="directive">CustomLog</code> directive, apart from the following
    differences:</p>
    <ul>
       <li><code class="directive">GlobalLog</code> is not valid in virtual host
            context.</li>
       <li><code class="directive">GlobalLog</code> is used by virtual hosts that
           define their own <code class="directive">CustomLog</code>, unlike a 
           globally specified <code class="directive">CustomLog</code>.</li>
    </ul>

</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="LogFormat" id="LogFormat">LogFormat</a> <a name="logformat" id="logformat">Directive</a> <a title="Permanent link" href="#logformat" class="permalink">&para;</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Describes a format for use in a log file</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LogFormat <var>format</var>|<var>nickname</var>
[<var>nickname</var>]</code></td></tr>
<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>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</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
    <var>format</var> as discussed in the <a href="#formats">custom log
    formats</a> section above. Alternatively, it can use a
    <var>nickname</var> 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 <var>format</var> with a
    <var>nickname</var>. This <var>nickname</var> can then be used in
    subsequent <code class="directive">LogFormat</code> or
    <code class="directive"><a href="#customlog">CustomLog</a></code> directives
    rather than repeating the entire format string. A
    <code class="directive">LogFormat</code> directive that 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"><a href="#transferlog">TransferLog</a></code> directives.
    In addition, <code class="directive">LogFormat</code> cannot use one nickname
    to define another nickname. Note that the nickname should not contain
    percent signs (<code>%</code>).</p>

    <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">LogFormat "%v %h %l %u %t \"%r\" %&gt;s %b" vhost_common</pre>
</div>


</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="TransferLog" id="TransferLog">TransferLog</a> <a name="transferlog" id="transferlog">Directive</a> <a title="Permanent link" href="#transferlog" class="permalink">&para;</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Specify location of a log file</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>TransferLog <var>file</var>|<var>pipe</var></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr>
</table>
    <p>This directive has exactly the same arguments and effect as
    the <code class="directive"><a href="#customlog">CustomLog</a></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
    <code class="directive"><a href="#logformat">LogFormat</a></code> directive
    which does not define a nickname. Common Log Format is used if no
    other format has been specified.</p>

    <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-agent}i\""
TransferLog "logs/access_log"</pre>
</div>

</div>
</div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="../en/mod/mod_log_config.html" title="English">&nbsp;en&nbsp;</a> |
<a href="../fr/mod/mod_log_config.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
<a href="../ja/mod/mod_log_config.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="../ko/mod/mod_log_config.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="../tr/mod/mod_log_config.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
</div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Libera.chat, or sent to our <a href="https://httpd.apache.org/lists.html">mailing lists</a>.</div>
<script type="text/javascript"><!--//--><![CDATA[//><!--
var comments_shortname = 'httpd';
var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_log_config.html';
(function(w, d) {
    if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
        d.write('<div id="comments_thread"><\/div>');
        var s = d.createElement('script');
        s.type = 'text/javascript';
        s.async = true;
        s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
        (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
    }
    else {
        d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
    }
})(window, document);
//--><!]]></script></div><div id="footer">
<p class="apache">Copyright 2023 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>
<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
if (typeof(prettyPrint) !== 'undefined') {
    prettyPrint();
}
//--><!]]></script>
</body></html>