]> granicus.if.org Git - apache/blob - docs/manual/logs.xml
update transformation
[apache] / docs / manual / logs.xml
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="./style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
5
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <manualpage metafile="logs.xml.meta">
24
25   <title>Log Files</title>
26
27   <summary>
28     <p>In order to effectively manage a web server, it is necessary
29     to get feedback about the activity and performance of the
30     server as well as any problems that may be occurring. The Apache HTTP Server
31     provides very comprehensive and flexible logging
32     capabilities. This document describes how to configure its
33     logging capabilities, and how to understand what the logs
34     contain.</p>
35   </summary>
36
37     <section id="overview">
38     <title>Overview</title>
39
40   <related>
41       <modulelist>
42         <module>mod_log_config</module>
43         <module>mod_log_forensic</module>
44         <module>mod_logio</module>
45         <module>mod_cgi</module>
46       </modulelist>
47   </related>
48
49   <p>
50   The Apache HTTP Server provides a variety of different mechanisms for
51   logging everything that happens on your server, from the initial
52   request, through the URL mapping process, to the final resolution of
53   the connection, including any errors that may have occurred in the
54   process. In addition to this, third-party modules may provide logging
55   capabilities, or inject entries into the existing log files, and
56   applications such as CGI programs, or PHP scripts, or other handlers,
57   may send messages to the server error log.
58   </p>
59
60   <p>
61   In this document we discuss the logging modules that are a standard
62   part of the http server.
63   </p>
64
65   </section>
66
67   <section id="security">
68     <title>Security Warning</title>
69
70     <p>Anyone who can write to the directory where Apache httpd is
71     writing a log file can almost certainly gain access to the uid
72     that the server is started as, which is normally root. Do
73     <em>NOT</em> give people write access to the directory the logs
74     are stored in without being aware of the consequences; see the
75     <a href="misc/security_tips.html">security tips</a> document
76     for details.</p>
77
78     <p>In addition, log files may contain information supplied
79     directly by the client, without escaping. Therefore, it is
80     possible for malicious clients to insert control-characters in
81     the log files, so care must be taken in dealing with raw
82     logs.</p>
83   </section>
84
85   <section id="errorlog">
86     <title>Error Log</title>
87
88     <related>
89       <modulelist>
90         <module>core</module>
91       </modulelist>
92       <directivelist>
93         <directive module="core">ErrorLog</directive>
94         <directive module="core">ErrorLogFormat</directive>
95         <directive module="core">LogLevel</directive>
96       </directivelist>
97     </related>
98
99     <p>The server error log, whose name and location is set by the
100     <directive module="core">ErrorLog</directive> directive, is the
101     most important log file. This is the place where Apache httpd
102     will send diagnostic information and record any errors that it
103     encounters in processing requests. It is the first place to
104     look when a problem occurs with starting the server or with the
105     operation of the server, since it will often contain details of
106     what went wrong and how to fix it.</p>
107
108     <p>The error log is usually written to a file (typically
109     <code>error_log</code> on Unix systems and
110     <code>error.log</code> on Windows and OS/2). On Unix systems it
111     is also possible to have the server send errors to
112     <code>syslog</code> or <a href="#piped">pipe them to a
113     program</a>.</p>
114
115     <p>The format of the error log is defined by the <directive
116     module="core">ErrorLogFormat</directive> directive, with which you
117     can customize what values are logged. A default is format defined
118     if you don't specify one. A typical log message follows:</p>
119
120     <example>
121     [Fri Sep 09 10:42:29.902022 2011] [core:error] [pid 35708:tid 4328636416]
122     [client 72.15.99.187] File does not exist: /usr/local/apache2/htdocs/favicon.ico
123     </example>
124
125     <p>The first item in the log entry is the date and time of the
126     message. The next is the module producing the message (core, in this
127     case) and the severity level of that message. This is followed by
128     the process ID and, if appropriate, the thread ID, of the process
129     that experienced the condition. Next, we have the client address
130     that made the request. And finally is the detailed error message,
131     which in this case indicates a request for a file that did not
132     exist.</p>
133
134     <p>A very wide variety of different messages can appear in the
135     error log. Most look similar to the example above. The error
136     log will also contain debugging output from CGI scripts. Any
137     information written to <code>stderr</code> by a CGI script will
138     be copied directly to the error log.</p>
139
140     <p>Putting a <code>%L</code> token in both the error log and the access
141     log will produce a log entry ID with which you can correlate the entry
142     in the error log with the entry in the access log. If
143     <module>mod_unique_id</module> is loaded, its unique request ID will be
144     used as the log entry ID, too.</p>
145
146     <p>During testing, it is often useful to continuously monitor
147     the error log for any problems. On Unix systems, you can
148     accomplish this using:</p>
149
150     <example>
151       tail -f error_log
152     </example>
153   </section>
154
155   <section id="permodule">
156     <title>Per-module logging</title>
157
158     <p>The <directive module="core">LogLevel</directive> directive
159     allows you to specify a log severity level on a per-module basis. In
160     this way, if you are troubleshooting a problem with just one
161     particular module, you can turn up its logging volume without also
162     getting the details of other modules that you're not interested in.
163     This is particularly useful for modules such as
164     <module>mod_proxy</module> or <module>mod_rewrite</module> where you
165     want to know details about what it's trying to do.</p>
166
167     <p>Do this by specifying the name of the module in your
168     <directive>LogLevel</directive> directive:</p>
169
170     <example>
171     LogLevel info rewrite:trace5
172     </example>
173
174     <p>This sets the main <directive>LogLevel</directive> to info, but
175     turns it up to <code>trace5</code> for
176     <module>mod_rewrite</module>.</p>
177
178     <note>This replaces the per-module logging directives, such as
179     <code>RewriteLog</code>, that were present in earlier versions of
180     the server.</note>
181   </section>
182
183   <section id="accesslog">
184     <title>Access Log</title>
185
186     <related>
187       <modulelist>
188         <module>mod_log_config</module>
189         <module>mod_setenvif</module>
190       </modulelist>
191       <directivelist>
192         <directive module="mod_log_config">CustomLog</directive>
193         <directive module="mod_log_config">LogFormat</directive>
194         <directive module="mod_setenvif">SetEnvIf</directive>
195       </directivelist>
196     </related>
197
198     <p>The server access log records all requests processed by the
199     server. The location and content of the access log are
200     controlled by the <directive module="mod_log_config">CustomLog</directive>
201     directive. The <directive module="mod_log_config">LogFormat</directive>
202     directive can be used to simplify the selection of
203     the contents of the logs. This section describes how to configure the server
204     to record information in the access log.</p>
205
206     <p>Of course, storing the information in the access log is only
207     the start of log management. The next step is to analyze this
208     information to produce useful statistics. Log analysis in
209     general is beyond the scope of this document, and not really
210     part of the job of the web server itself. For more information
211     about this topic, and for applications which perform log
212     analysis, check the <a
213     href="http://dmoz.org/Computers/Software/Internet/Site_Management/Log_analysis/">
214     Open Directory</a> or <a
215     href="http://dir.yahoo.com/Computers_and_Internet/Software/Internet/World_Wide_Web/Servers/Log_Analysis_Tools/">
216     Yahoo</a>.</p>
217
218     <p>Various versions of Apache httpd have used other modules and
219     directives to control access logging, including
220     mod_log_referer, mod_log_agent, and the
221     <code>TransferLog</code> directive. The <directive
222     module="mod_log_config">CustomLog</directive> directive now subsumes
223     the functionality of all the older directives.</p>
224
225     <p>The format of the access log is highly configurable. The format
226     is specified using a format string that looks much like a C-style
227     printf(1) format string. Some examples are presented in the next
228     sections. For a complete list of the possible contents of the
229     format string, see the <module>mod_log_config</module> <a
230     href="mod/mod_log_config.html#formats">format strings</a>.</p>
231
232     <section id="common">
233       <title>Common Log Format</title>
234
235       <p>A typical configuration for the access log might look as
236       follows.</p>
237
238       <example>
239         LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common<br />
240          CustomLog logs/access_log common
241       </example>
242
243       <p>This defines the <em>nickname</em> <code>common</code> and
244       associates it with a particular log format string. The format
245       string consists of percent directives, each of which tell the
246       server to log a particular piece of information. Literal
247       characters may also be placed in the format string and will be
248       copied directly into the log output. The quote character
249       (<code>"</code>) must be escaped by placing a backslash before
250       it to prevent it from being interpreted as the end of the
251       format string. The format string may also contain the special
252       control characters "<code>\n</code>" for new-line and
253       "<code>\t</code>" for tab.</p>
254
255       <p>The <directive module="mod_log_config">CustomLog</directive>
256       directive sets up a new log file using the defined
257       <em>nickname</em>. The filename for the access log is relative to
258       the <directive module="core">ServerRoot</directive> unless it
259       begins with a slash.</p>
260
261       <p>The above configuration will write log entries in a format
262       known as the Common Log Format (CLF). This standard format can
263       be produced by many different web servers and read by many log
264       analysis programs. The log file entries produced in CLF will
265       look something like this:</p>
266
267       <example>
268         127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET
269         /apache_pb.gif HTTP/1.0" 200 2326
270       </example>
271
272       <p>Each part of this log entry is described below.</p>
273
274       <dl>
275         <dt><code>127.0.0.1</code> (<code>%h</code>)</dt>
276
277         <dd>This is the IP address of the client (remote host) which
278         made the request to the server. If <directive
279         module="core">HostnameLookups</directive> is
280         set to <code>On</code>, then the server will try to determine
281         the hostname and log it in place of the IP address. However,
282         this configuration is not recommended since it can
283         significantly slow the server. Instead, it is best to use a
284         log post-processor such as <program>logresolve</program> to determine
285         the hostnames. The IP address reported here is not
286         necessarily the address of the machine at which the user is
287         sitting. If a proxy server exists between the user and the
288         server, this address will be the address of the proxy, rather
289         than the originating machine.</dd>
290
291         <dt><code>-</code> (<code>%l</code>)</dt>
292
293         <dd>The "hyphen" in the output indicates that the requested
294         piece of information is not available. In this case, the
295         information that is not available is the RFC 1413 identity of
296         the client determined by <code>identd</code> on the clients
297         machine. This information is highly unreliable and should
298         almost never be used except on tightly controlled internal
299         networks. Apache httpd will not even attempt to determine
300         this information unless <directive
301         module="core">IdentityCheck</directive> is set
302         to <code>On</code>.</dd>
303
304         <dt><code>frank</code> (<code>%u</code>)</dt>
305
306         <dd>This is the userid of the person requesting the document
307         as determined by HTTP authentication. The same value is
308         typically provided to CGI scripts in the
309         <code>REMOTE_USER</code> environment variable. If the status
310         code for the request (see below) is 401, then this value
311         should not be trusted because the user is not yet
312         authenticated. If the document is not password protected,
313         this part will be "<code>-</code>" just like the previous
314         one.</dd>
315
316         <dt><code>[10/Oct/2000:13:55:36 -0700]</code>
317         (<code>%t</code>)</dt>
318
319         <dd>
320           The time that the request was received.
321           The format is:
322
323           <p class="indent">
324             <code>[day/month/year:hour:minute:second zone]<br />
325              day = 2*digit<br />
326              month = 3*letter<br />
327              year = 4*digit<br />
328              hour = 2*digit<br />
329              minute = 2*digit<br />
330              second = 2*digit<br />
331              zone = (`+' | `-') 4*digit</code>
332           </p>
333           <p>It is possible to have the time displayed in another format
334           by specifying <code>%{format}t</code> in the log format
335           string, where <code>format</code> is either as in
336           <code>strftime(3)</code> from the C standard library,
337           or one of the supported special tokens. For details see
338           the <module>mod_log_config</module> <a
339           href="mod/mod_log_config.html#formats">format strings</a>.</p>
340         </dd>
341
342         <dt><code>"GET /apache_pb.gif HTTP/1.0"</code>
343         (<code>\"%r\"</code>)</dt>
344
345         <dd>The request line from the client is given in double
346         quotes. The request line contains a great deal of useful
347         information. First, the method used by the client is
348         <code>GET</code>. Second, the client requested the resource
349         <code>/apache_pb.gif</code>, and third, the client used the
350         protocol <code>HTTP/1.0</code>. It is also possible to log
351         one or more parts of the request line independently. For
352         example, the format string "<code>%m %U%q %H</code>" will log
353         the method, path, query-string, and protocol, resulting in
354         exactly the same output as "<code>%r</code>".</dd>
355
356         <dt><code>200</code> (<code>%&gt;s</code>)</dt>
357
358         <dd>This is the status code that the server sends back to the
359         client. This information is very valuable, because it reveals
360         whether the request resulted in a successful response (codes
361         beginning in 2), a redirection (codes beginning in 3), an
362         error caused by the client (codes beginning in 4), or an
363         error in the server (codes beginning in 5). The full list of
364         possible status codes can be found in the <a
365         href="http://www.w3.org/Protocols/rfc2616/rfc2616.txt">HTTP
366         specification</a> (RFC2616 section 10).</dd>
367
368         <dt><code>2326</code> (<code>%b</code>)</dt>
369
370         <dd>The last part indicates the size of the object returned
371         to the client, not including the response headers. If no
372         content was returned to the client, this value will be
373         "<code>-</code>". To log "<code>0</code>" for no content, use
374         <code>%B</code> instead.</dd>
375       </dl>
376     </section>
377
378     <section id="combined">
379       <title>Combined Log Format</title>
380
381       <p>Another commonly used format string is called the Combined
382       Log Format. It can be used as follows.</p>
383
384       <example>
385         LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\"
386         \"%{User-agent}i\"" combined<br />
387          CustomLog log/access_log combined
388       </example>
389
390       <p>This format is exactly the same as the Common Log Format,
391       with the addition of two more fields. Each of the additional
392       fields uses the percent-directive
393       <code>%{<em>header</em>}i</code>, where <em>header</em> can be
394       any HTTP request header. The access log under this format will
395       look like:</p>
396
397       <example>
398         127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET
399         /apache_pb.gif HTTP/1.0" 200 2326
400         "http://www.example.com/start.html" "Mozilla/4.08 [en]
401         (Win98; I ;Nav)"
402       </example>
403
404       <p>The additional fields are:</p>
405
406       <dl>
407         <dt><code>"http://www.example.com/start.html"</code>
408         (<code>\"%{Referer}i\"</code>)</dt>
409
410         <dd>The "Referer" (sic) HTTP request header. This gives the
411         site that the client reports having been referred from. (This
412         should be the page that links to or includes
413         <code>/apache_pb.gif</code>).</dd>
414
415         <dt><code>"Mozilla/4.08 [en] (Win98; I ;Nav)"</code>
416         (<code>\"%{User-agent}i\"</code>)</dt>
417
418         <dd>The User-Agent HTTP request header. This is the
419         identifying information that the client browser reports about
420         itself.</dd>
421       </dl>
422     </section>
423
424     <section id="multiple">
425       <title>Multiple Access Logs</title>
426
427       <p>Multiple access logs can be created simply by specifying
428       multiple <directive module="mod_log_config">CustomLog</directive>
429       directives in the configuration
430       file. For example, the following directives will create three
431       access logs. The first contains the basic CLF information,
432       while the second and third contain referer and browser
433       information. The last two <directive
434       module="mod_log_config">CustomLog</directive> lines show how
435       to mimic the effects of the <code>ReferLog</code> and <code
436       >AgentLog</code> directives.</p>
437
438       <example>
439         LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common<br />
440         CustomLog logs/access_log common<br />
441         CustomLog logs/referer_log "%{Referer}i -&gt; %U"<br />
442         CustomLog logs/agent_log "%{User-agent}i"
443       </example>
444
445       <p>This example also shows that it is not necessary to define a
446       nickname with the <directive
447       module="mod_log_config">LogFormat</directive> directive. Instead,
448       the log format can be specified directly in the <directive
449       module="mod_log_config">CustomLog</directive> directive.</p>
450     </section>
451
452     <section id="conditional">
453       <title>Conditional Logs</title>
454
455       <p>There are times when it is convenient to exclude certain
456       entries from the access logs based on characteristics of the
457       client request. This is easily accomplished with the help of <a
458       href="env.html">environment variables</a>. First, an
459       environment variable must be set to indicate that the request
460       meets certain conditions. This is usually accomplished with
461       <directive module="mod_setenvif">SetEnvIf</directive>. Then the
462       <code>env=</code> clause of the <directive
463       module="mod_log_config">CustomLog</directive> directive is used to
464       include or exclude requests where the environment variable is
465       set. Some examples:</p>
466
467       <example>
468         # Mark requests from the loop-back interface<br />
469         SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog<br />
470         # Mark requests for the robots.txt file<br />
471         SetEnvIf Request_URI "^/robots\.txt$" dontlog<br />
472         # Log what remains<br />
473         CustomLog logs/access_log common env=!dontlog
474       </example>
475
476       <p>As another example, consider logging requests from
477       english-speakers to one log file, and non-english speakers to a
478       different log file.</p>
479
480       <example>
481         SetEnvIf Accept-Language "en" english<br />
482         CustomLog logs/english_log common env=english<br />
483         CustomLog logs/non_english_log common env=!english
484       </example>
485
486       <p>In a caching scenario one would want to know about
487       the efficiency of the cache. A very simple method to
488       find this out would be:</p>
489
490       <example>
491         SetEnv CACHE_MISS 1<br />
492         LogFormat "%h %l %u %t "%r " %>s %b %{CACHE_MISS}e" common-cache<br />
493         CustomLog logs/access_log common-cache
494       </example>
495
496       <p><module>mod_cache</module> will run before
497       <module>mod_env</module> and when successfull will deliver the
498       content without it. In that case a cache hit will log
499       <code>-</code>, while a cache miss will log <code>1</code>.</p>
500
501       <p>In addition to the <code>env=</code> syntax, <directive
502       module="mod_log_config">LogFormat</directive> supports logging values
503       conditional upon the HTTP response code:</p>
504
505       <example>
506       LogFormat "%400,501{User-agent}i" browserlog<br />
507       LogFormat "%!200,304,302{Referer}i" refererlog
508       </example>
509
510       <p>In the first example, the <code>User-agent</code> will be
511       logged if the HTTP status code is 400 or 501. In other cases, a
512       literal "-" will be logged instead. Likewise, in the second
513       example, the <code>Referer</code> will be logged if the HTTP
514       status code is <strong>not</strong> 200, 204, or 302. (Note the
515       "!" before the status codes.</p>
516
517       <p>Although we have just shown that conditional logging is very
518       powerful and flexible, it is not the only way to control the
519       contents of the logs. Log files are more useful when they
520       contain a complete record of server activity. It is often
521       easier to simply post-process the log files to remove requests
522       that you do not want to consider.</p>
523     </section>
524   </section>
525
526   <section id="rotation">
527     <title>Log Rotation</title>
528
529     <p>On even a moderately busy server, the quantity of
530     information stored in the log files is very large. The access
531     log file typically grows 1 MB or more per 10,000 requests. It
532     will consequently be necessary to periodically rotate the log
533     files by moving or deleting the existing logs. This cannot be
534     done while the server is running, because Apache httpd will continue
535     writing to the old log file as long as it holds the file open.
536     Instead, the server must be <a
537     href="stopping.html">restarted</a> after the log files are
538     moved or deleted so that it will open new log files.</p>
539
540     <p>By using a <em>graceful</em> restart, the server can be
541     instructed to open new log files without losing any existing or
542     pending connections from clients. However, in order to
543     accomplish this, the server must continue to write to the old
544     log files while it finishes serving old requests. It is
545     therefore necessary to wait for some time after the restart
546     before doing any processing on the log files. A typical
547     scenario that simply rotates the logs and compresses the old
548     logs to save space is:</p>
549
550     <example>
551       mv access_log access_log.old<br />
552       mv error_log error_log.old<br />
553       apachectl graceful<br />
554       sleep 600<br />
555       gzip access_log.old error_log.old
556     </example>
557
558     <p>Another way to perform log rotation is using <a
559     href="#piped">piped logs</a> as discussed in the next
560     section.</p>
561   </section>
562
563   <section id="piped">
564     <title>Piped Logs</title>
565
566     <p>Apache httpd is capable of writing error and access log
567     files through a pipe to another process, rather than directly
568     to a file. This capability dramatically increases the
569     flexibility of logging, without adding code to the main server.
570     In order to write logs to a pipe, simply replace the filename
571     with the pipe character "<code>|</code>", followed by the name
572     of the executable which should accept log entries on its
573     standard input. The server will start the piped-log process when
574     the server starts, and will restart it if it crashes while the
575     server is running. (This last feature is why we can refer to
576     this technique as "reliable piped logging".)</p>
577
578     <p>Piped log processes are spawned by the parent Apache httpd
579     process, and inherit the userid of that process. This means
580     that piped log programs usually run as root. It is therefore
581     very important to keep the programs simple and secure.</p>
582
583     <p>One important use of piped logs is to allow log rotation
584     without having to restart the server. The Apache HTTP Server
585     includes a simple program called <program>rotatelogs</program>
586     for this purpose. For example, to rotate the logs every 24 hours, you
587     can use:</p>
588
589     <example>
590       CustomLog "|/usr/local/apache/bin/rotatelogs
591       /var/log/access_log 86400" common
592     </example>
593
594     <p>Notice that quotes are used to enclose the entire command
595     that will be called for the pipe. Although these examples are
596     for the access log, the same technique can be used for the
597     error log.</p>
598
599     <p>A similar but much more flexible log rotation program
600     called <a href="http://www.cronolog.org/">cronolog</a>
601     is available at an external site.</p>
602
603     <p>As with conditional logging, piped logs are a very powerful
604     tool, but they should not be used where a simpler solution like
605     off-line post-processing is available.</p>
606
607     <p>By default the piped log process is spawned without invoking
608     a shell. Use "<code>|$</code>" instead of "<code>|</code>"
609     to spawn using a shell (usually with <code>/bin/sh -c</code>):</p>
610
611     <example>
612       # Invoke "rotatelogs" using a shell<br />
613       CustomLog "|$/usr/local/apache/bin/rotatelogs
614       /var/log/access_log 86400" common
615     </example>
616
617     <p>This was the default behaviour for Apache 2.2.
618     Depending on the shell specifics this might lead to
619     an additional shell process for the lifetime of the logging
620     pipe program and signal handling problems during restart.
621     For compatibility reasons with Apache 2.2 the notation
622     "<code>||</code>" is also supported and equivalent to using
623     "<code>|</code>".</p>
624   </section>
625
626   <section id="virtualhost">
627     <title>Virtual Hosts</title>
628
629     <p>When running a server with many <a href="vhosts/">virtual
630     hosts</a>, there are several options for dealing with log
631     files. First, it is possible to use logs exactly as in a
632     single-host server. Simply by placing the logging directives
633     outside the <directive module="core"
634     type="section">VirtualHost</directive> sections in the
635     main server context, it is possible to log all requests in the
636     same access log and error log. This technique does not allow
637     for easy collection of statistics on individual virtual
638     hosts.</p>
639
640     <p>If <directive module="mod_log_config">CustomLog</directive>
641     or <directive module="core">ErrorLog</directive>
642     directives are placed inside a
643     <directive module="core" type="section">VirtualHost</directive>
644     section, all requests or errors for that virtual host will be
645     logged only to the specified file. Any virtual host which does
646     not have logging directives will still have its requests sent
647     to the main server logs. This technique is very useful for a
648     small number of virtual hosts, but if the number of hosts is
649     very large, it can be complicated to manage. In addition, it
650     can often create problems with <a
651     href="vhosts/fd-limits.html">insufficient file
652     descriptors</a>.</p>
653
654     <p>For the access log, there is a very good compromise. By
655     adding information on the virtual host to the log format
656     string, it is possible to log all hosts to the same log, and
657     later split the log into individual files. For example,
658     consider the following directives.</p>
659
660     <example>
661       LogFormat "%v %l %u %t \"%r\" %&gt;s %b"
662       comonvhost<br />
663       CustomLog logs/access_log comonvhost
664     </example>
665
666     <p>The <code>%v</code> is used to log the name of the virtual
667     host that is serving the request. Then a program like <a
668     href="programs/other.html">split-logfile</a> can be used to
669     post-process the access log in order to split it into one file
670     per virtual host.</p>
671   </section>
672
673   <section id="other">
674     <title>Other Log Files</title>
675
676     <related>
677       <modulelist>
678         <module>mod_logio</module>
679         <module>mod_log_config</module>
680         <module>mod_log_forensic</module>
681         <module>mod_cgi</module>
682       </modulelist>
683
684       <directivelist>
685         <directive module="mod_log_config">LogFormat</directive>
686         <directive module="mod_log_config">BufferedLogs</directive>
687         <directive module="mod_log_forensic">ForensicLog</directive>
688         <directive module="mpm_common">PidFile</directive>
689         <directive module="mod_cgi">ScriptLog</directive>
690         <directive module="mod_cgi">ScriptLogBuffer</directive>
691         <directive module="mod_cgi">ScriptLogLength</directive>
692       </directivelist>
693     </related>
694
695     <section>
696       <title>Logging actual bytes sent and received</title>
697
698       <p><module>mod_logio</module> adds in two additional
699          <directive module="mod_log_config">LogFormat</directive> fields
700          (%I and %O) that log the actual number of bytes received and sent
701          on the network.</p>
702     </section>
703
704     <section>
705       <title>Forensic Logging</title>
706
707       <p><module>mod_log_forensic</module> provides for forensic logging of
708          client requests. Logging is done before and after processing a
709          request, so the forensic log contains two log lines for each
710          request. The forensic logger is very strict with no customizations.
711          It can be an invaluable debugging and security tool.</p>
712     </section>
713
714     <section id="pidfile">
715       <title>PID File</title>
716
717       <p>On startup, Apache httpd saves the process id of the parent
718       httpd process to the file <code>logs/httpd.pid</code>. This
719       filename can be changed with the <directive
720       module="mpm_common">PidFile</directive> directive. The
721       process-id is for use by the administrator in restarting and
722       terminating the daemon by sending signals to the parent
723       process; on Windows, use the -k command line option instead.
724       For more information see the <a href="stopping.html">Stopping
725       and Restarting</a> page.</p>
726     </section>
727
728     <section id="scriptlog">
729       <title>Script Log</title>
730
731       <p>In order to aid in debugging, the
732       <directive module="mod_cgi">ScriptLog</directive> directive
733       allows you to record the input to and output from CGI scripts.
734       This should only be used in testing - not for live servers.
735       More information is available in the <a
736       href="mod/mod_cgi.html">mod_cgi</a> documentation.</p>
737     </section>
738
739   </section>
740 </manualpage>
741
742
743
744