]> granicus.if.org Git - apache/blob - docs/manual/logs.html.en
update transformation
[apache] / docs / manual / logs.html.en
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>Log Files - 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 id="manual-page"><div id="page-header">
14 <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>
15 <p class="apache">Apache HTTP Server Version 2.1</p>
16 <img alt="" src="./images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
18 <div id="path">
19 <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-project/">Documentation</a> &gt; <a href="./">Version 2.1</a></div><div id="page-content"><div id="preamble"><h1>Log Files</h1>
20 <div class="toplang">
21 <p><span>Available Languages: </span><a href="./en/logs.html" title="English">&nbsp;en&nbsp;</a> |
22 <a href="./ja/logs.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
23 <a href="./ko/logs.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
24 </div>
25
26     <p>In order to effectively manage a web server, it is necessary
27     to get feedback about the activity and performance of the
28     server as well as any problems that may be occurring. The Apache
29     HTTP Server provides very comprehensive and flexible logging
30     capabilities. This document describes how to configure its
31     logging capabilities, and how to understand what the logs
32     contain.</p>
33   </div>
34 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#security">Security Warning</a></li>
35 <li><img alt="" src="./images/down.gif" /> <a href="#errorlog">Error Log</a></li>
36 <li><img alt="" src="./images/down.gif" /> <a href="#accesslog">Access Log</a></li>
37 <li><img alt="" src="./images/down.gif" /> <a href="#rotation">Log Rotation</a></li>
38 <li><img alt="" src="./images/down.gif" /> <a href="#piped">Piped Logs</a></li>
39 <li><img alt="" src="./images/down.gif" /> <a href="#virtualhost">Virtual Hosts</a></li>
40 <li><img alt="" src="./images/down.gif" /> <a href="#other">Other Log Files</a></li>
41 </ul></div>
42 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
43 <div class="section">
44 <h2><a name="security" id="security">Security Warning</a></h2>
45     
46     
47     <p>Anyone who can write to the directory where Apache is
48     writing a log file can almost certainly gain access to the uid
49     that the server is started as, which is normally root. Do
50     <em>NOT</em> give people write access to the directory the logs
51     are stored in without being aware of the consequences; see the
52     <a href="misc/security_tips.html">security tips</a> document
53     for details.</p>
54
55     <p>In addition, log files may contain information supplied
56     directly by the client, without escaping. Therefore, it is
57     possible for malicious clients to insert control-characters in
58     the log files, so care must be taken in dealing with raw
59     logs.</p>
60   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
61 <div class="section">
62 <h2><a name="errorlog" id="errorlog">Error Log</a></h2>
63     
64     
65     <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td /><td><ul><li><code class="directive"><a href="./mod/core.html#errorlog">ErrorLog</a></code></li><li><code class="directive"><a href="./mod/core.html#loglevel">LogLevel</a></code></li></ul></td></tr></table>
66     
67     <p>The server error log, whose name and location is set by the
68     <code class="directive"><a href="./mod/core.html#errorlog">ErrorLog</a></code> directive, is the
69     most important log file. This is the place where Apache httpd
70     will send diagnostic information and record any errors that it
71     encounters in processing requests. It is the first place to
72     look when a problem occurs with starting the server or with the
73     operation of the server, since it will often contain details of
74     what went wrong and how to fix it.</p>
75
76     <p>The error log is usually written to a file (typically
77     <code>error_log</code> on unix systems and
78     <code>error.log</code> on Windows and OS/2). On unix systems it
79     is also possible to have the server send errors to
80     <code>syslog</code> or <a href="#piped">pipe them to a
81     program</a>.</p>
82     
83     <p>The format of the error log is relatively free-form and
84     descriptive. But there is certain information that is contained
85     in most error log entries. For example, here is a typical
86     message.</p>
87     
88     <div class="example"><p><code>
89       [Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1]
90       client denied by server configuration:
91       /export/home/live/ap/htdocs/test
92     </code></p></div>
93     
94     <p>The first item in the log entry is the date and time of the
95     message. The second entry lists the severity of the error being
96     reported. The <code class="directive"><a href="./mod/core.html#loglevel">LogLevel</a></code>
97     directive is used to control the types of errors that are sent
98     to the error log by restricting the severity level. The third
99     entry gives the IP address of the client that generated the
100     error. Beyond that is the message itself, which in this case
101     indicates that the server has been configured to deny the
102     client access. The server reports the file-system path (as
103     opposed to the web path) of the requested document.</p>
104
105     <p>A very wide variety of different messages can appear in the
106     error log. Most look similar to the example above. The error
107     log will also contain debugging output from CGI scripts. Any
108     information written to <code>stderr</code> by a CGI script will
109     be copied directly to the error log.</p>
110
111     <p>It is not possible to customize the error log by adding or
112     removing information. However, error log entries dealing with
113     particular requests have corresponding entries in the <a href="#accesslog">access log</a>. For example, the above example
114     entry corresponds to an access log entry with status code 403.
115     Since it is possible to customize the access log, you can
116     obtain more information about error conditions using that log
117     file.</p>
118     
119     <p>During testing, it is often useful to continuously monitor
120     the error log for any problems. On unix systems, you can
121     accomplish this using:</p>
122     
123     <div class="example"><p><code>
124       tail -f error_log
125     </code></p></div>
126   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
127 <div class="section">
128 <h2><a name="accesslog" id="accesslog">Access Log</a></h2>
129     
130     
131     <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="./mod/mod_log_config.html">mod_log_config</a></code></li><li><code class="module"><a href="./mod/mod_setenvif.html">mod_setenvif</a></code></li></ul></td><td><ul><li><code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code></li><li><code class="directive"><a href="./mod/mod_log_config.html#logformat">LogFormat</a></code></li><li><code class="directive"><a href="./mod/mod_setenvif.html#setenvif">SetEnvIf</a></code></li></ul></td></tr></table>
132     
133     <p>The server access log records all requests processed by the
134     server. The location and content of the access log are
135     controlled by the <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code>
136     directive. The <code class="directive"><a href="./mod/mod_log_config.html#logformat">LogFormat</a></code>
137     directive can be used to simplify the selection of 
138     the contents of the logs. This section describes how to configure the server
139     to record information in the access log.</p>
140
141     <p>Of course, storing the information in the access log is only
142     the start of log management. The next step is to analyze this
143     information to produce useful statistics. Log analysis in
144     general is beyond the scope of this document, and not really
145     part of the job of the web server itself. For more information
146     about this topic, and for applications which perform log
147     analysis, check the <a href="http://dmoz.org/Computers/Software/Internet/Site_Management/Log_analysis/">
148     Open Directory</a> or <a href="http://dir.yahoo.com/Computers_and_Internet/Software/Internet/World_Wide_Web/Servers/Log_Analysis_Tools/">
149     Yahoo</a>.</p>
150     
151     <p>Various versions of Apache httpd have used other modules and
152     directives to control access logging, including
153     mod_log_referer, mod_log_agent, and the
154     <code>TransferLog</code> directive. The <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code> directive now subsumes
155         the functionality of all the older directives.</p>
156
157     <p>The format of the access log is highly configurable. The format
158     is specified using a format string that looks much like a C-style
159     printf(1) format string. Some examples are presented in the next
160     sections. For a complete list of the possible contents of the
161     format string, see the <code class="module"><a href="./mod/mod_log_config.html">mod_log_config</a></code> <a href="mod/mod_log_config.html#formats">format strings</a>.</p>
162     
163     <h3><a name="common" id="common">Common Log Format</a></h3>
164       
165     
166       <p>A typical configuration for the access log might look as
167       follows.</p>
168
169       <div class="example"><p><code>
170         LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common<br />
171          CustomLog logs/access_log common
172       </code></p></div>
173     
174       <p>This defines the <em>nickname</em> <code>common</code> and
175       associates it with a particular log format string. The format
176       string consists of percent directives, each of which tell the
177       server to log a particular piece of information. Literal
178       characters may also be placed in the format string and will be
179       copied directly into the log output. The quote character
180       (<code>"</code>) must be escaped by placing a back-slash before
181       it to prevent it from being interpreted as the end of the
182       format string. The format string may also contain the special
183       control characters "<code>\n</code>" for new-line and
184       "<code>\t</code>" for tab.</p>
185
186       <p>The <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code>
187           directive sets up a new log file using the defined
188           <em>nickname</em>. The filename for the access log is relative to
189           the <code class="directive"><a href="./mod/core.html#serverroot">ServerRoot</a></code> unless it
190           begins with a slash.</p>
191     
192       <p>The above configuration will write log entries in a format
193       known as the Common Log Format (CLF). This standard format can
194       be produced by many different web servers and read by many log
195       analysis programs. The log file entries produced in CLF will
196       look something like this:</p>
197
198       <div class="example"><p><code>
199         127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET
200         /apache_pb.gif HTTP/1.0" 200 2326
201       </code></p></div>
202     
203       <p>Each part of this log entry is described below.</p>
204     
205       <dl>
206         <dt><code>127.0.0.1</code> (<code>%h</code>)</dt>
207
208         <dd>This is the IP address of the client (remote host) which
209         made the request to the server. If <code class="directive"><a href="./mod/core.html#hostnamelookups">HostnameLookups</a></code> is
210         set to <code>On</code>, then the server will try to determine
211         the hostname and log it in place of the IP address. However,
212         this configuration is not recommended since it can
213         significantly slow the server. Instead, it is best to use a
214         log post-processor such as <a href="programs/logresolve.html">logresolve</a> to determine
215         the hostnames. The IP address reported here is not
216         necessarily the address of the machine at which the user is
217         sitting. If a proxy server exists between the user and the
218         server, this address will be the address of the proxy, rather
219         than the originating machine.</dd>
220
221         <dt><code>-</code> (<code>%l</code>)</dt>
222
223         <dd>The "hyphen" in the output indicates that the requested
224         piece of information is not available. In this case, the
225         information that is not available is the RFC 1413 identity of
226         the client determined by <code>identd</code> on the clients
227         machine. This information is highly unreliable and should
228         almost never be used except on tightly controlled internal
229         networks. Apache httpd will not even attempt to determine
230         this information unless <code class="directive"><a href="./mod/core.html#identitycheck">IdentityCheck</a></code> is set
231         to <code>On</code>.</dd>
232
233         <dt><code>frank</code> (<code>%u</code>)</dt>
234
235         <dd>This is the userid of the person requesting the document
236         as determined by HTTP authentication. The same value is
237         typically provided to CGI scripts in the
238         <code>REMOTE_USER</code> environment variable. If the status
239         code for the request (see below) is 401, then this value
240         should not be trusted because the user is not yet
241         authenticated. If the document is not password protected,
242         this entry will be "<code>-</code>" just like the previous
243         one.</dd>
244
245         <dt><code>[10/Oct/2000:13:55:36 -0700]</code>
246         (<code>%t</code>)</dt>
247
248         <dd>
249           The time that the server finished processing the request.
250           The format is: 
251
252           <p class="indent">
253             <code>[day/month/year:hour:minute:second zone]<br />
254              day = 2*digit<br />
255              month = 3*letter<br />
256              year = 4*digit<br />
257              hour = 2*digit<br />
258              minute = 2*digit<br />
259              second = 2*digit<br />
260              zone = (`+' | `-') 4*digit</code>
261           </p>
262           It is possible to have the time displayed in another format
263           by specifying <code>%{format}t</code> in the log format
264           string, where <code>format</code> is as in
265           <code>strftime(3)</code> from the C standard library.
266         </dd>
267
268         <dt><code>"GET /apache_pb.gif HTTP/1.0"</code>
269         (<code>\"%r\"</code>)</dt>
270
271         <dd>The request line from the client is given in double
272         quotes. The request line contains a great deal of useful
273         information. First, the method used by the client is
274         <code>GET</code>. Second, the client requested the resource
275         <code>/apache_pb.gif</code>, and third, the client used the
276         protocol <code>HTTP/1.0</code>. It is also possible to log
277         one or more parts of the request line independently. For
278         example, the format string "<code>%m %U%q %H</code>" will log
279         the method, path, query-string, and protocol, resulting in
280         exactly the same output as "<code>%r</code>".</dd>
281
282         <dt><code>200</code> (<code>%&gt;s</code>)</dt>
283
284         <dd>This is the status code that the server sends back to the
285         client. This information is very valuable, because it reveals
286         whether the request resulted in a successful response (codes
287         beginning in 2), a redirection (codes beginning in 3), an
288         error caused by the client (codes beginning in 4), or an
289         error in the server (codes beginning in 5). The full list of
290         possible status codes can be found in the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.txt">HTTP
291         specification</a> (RFC2616 section 10).</dd>
292
293         <dt><code>2326</code> (<code>%b</code>)</dt>
294
295         <dd>The last entry indicates the size of the object returned
296         to the client, not including the response headers. If no
297         content was returned to the client, this value will be
298         "<code>-</code>". To log "<code>0</code>" for no content, use
299         <code>%B</code> instead.</dd>
300       </dl>
301     
302     
303     <h3><a name="combined" id="combined">Combined Log Format</a></h3>
304       
305       
306       <p>Another commonly used format string is called the Combined
307       Log Format. It can be used as follows.</p>
308
309       <div class="example"><p><code>
310         LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\"
311         \"%{User-agent}i\"" combined<br />
312          CustomLog log/access_log combined
313       </code></p></div>
314
315       <p>This format is exactly the same as the Common Log Format,
316       with the addition of two more fields. Each of the additional
317       fields uses the percent-directive
318       <code>%{<em>header</em>}i</code>, where <em>header</em> can be
319       any HTTP request header. The access log under this format will
320       look like:</p>
321       
322       <div class="example"><p><code>
323         127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET
324         /apache_pb.gif HTTP/1.0" 200 2326
325         "http://www.example.com/start.html" "Mozilla/4.08 [en]
326         (Win98; I ;Nav)"
327       </code></p></div>
328
329       <p>The additional fields are:</p>
330       
331       <dl>
332         <dt><code>"http://www.example.com/start.html"</code>
333         (<code>\"%{Referer}i\"</code>)</dt>
334
335         <dd>The "Referer" (sic) HTTP request header. This gives the
336         site that the client reports having been referred from. (This
337         should be the page that links to or includes
338         <code>/apache_pb.gif</code>).</dd>
339
340         <dt><code>"Mozilla/4.08 [en] (Win98; I ;Nav)"</code>
341         (<code>\"%{User-agent}i\"</code>)</dt>
342
343         <dd>The User-Agent HTTP request header. This is the
344         identifying information that the client browser reports about
345         itself.</dd>
346       </dl>
347     
348     
349     <h3><a name="multiple" id="multiple">Multiple Access Logs</a></h3>
350       
351       
352       <p>Multiple access logs can be created simply by specifying
353       multiple <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code> 
354       directives in the configuration
355       file. For example, the following directives will create three
356       access logs. The first contains the basic CLF information,
357       while the second and third contain referer and browser
358       information. The last two <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code> lines show how
359       to mimic the effects of the <code>ReferLog</code> and <code>AgentLog</code> directives.</p>
360
361       <div class="example"><p><code>
362         LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common<br />
363         CustomLog logs/access_log common<br />
364         CustomLog logs/referer_log "%{Referer}i -&gt; %U"<br />
365         CustomLog logs/agent_log "%{User-agent}i"
366       </code></p></div>
367
368       <p>This example also shows that it is not necessary to define a
369       nickname with the <code class="directive"><a href="./mod/mod_log_config.html#logformat">LogFormat</a></code> directive. Instead,
370       the log format can be specified directly in the <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code> directive.</p>
371     
372     
373     <h3><a name="conditional" id="conditional">Conditional Logs</a></h3>
374       
375       
376       <p>There are times when it is convenient to exclude certain
377       entries from the access logs based on characteristics of the
378       client request. This is easily accomplished with the help of <a href="env.html">environment variables</a>. First, an
379       environment variable must be set to indicate that the request
380       meets certain conditions. This is usually accomplished with 
381       <code class="directive"><a href="./mod/mod_setenvif.html#setenvif">SetEnvIf</a></code>. Then the
382       <code>env=</code> clause of the <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code> directive is used to
383           include or exclude requests where the environment variable is
384           set. Some examples:</p>
385
386       <div class="example"><p><code>
387         # Mark requests from the loop-back interface<br />
388         SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog<br />
389         # Mark requests for the robots.txt file<br />
390         SetEnvIf Request_URI "^/robots\.txt$" dontlog<br />
391         # Log what remains<br />
392         CustomLog logs/access_log common env=!dontlog
393       </code></p></div>
394
395       <p>As another example, consider logging requests from
396       english-speakers to one log file, and non-english speakers to a
397       different log file.</p>
398
399       <div class="example"><p><code>
400         SetEnvIf Accept-Language "en" english<br />
401         CustomLog logs/english_log common env=english<br />
402         CustomLog logs/non_english_log common env=!english
403       </code></p></div>
404
405       <p>Although we have just shown that conditional logging is very
406       powerful and flexibly, it is not the only way to control the
407       contents of the logs. Log files are more useful when they
408       contain a complete record of server activity. It is often
409       easier to simply post-process the log files to remove requests
410       that you do not want to consider.</p>
411     
412   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
413 <div class="section">
414 <h2><a name="rotation" id="rotation">Log Rotation</a></h2>
415     
416     
417     <p>On even a moderately busy server, the quantity of
418     information stored in the log files is very large. The access
419     log file typically grows 1 MB or more per 10,000 requests. It
420     will consequently be necessary to periodically rotate the log
421     files by moving or deleting the existing logs. This cannot be
422     done while the server is running, because Apache will continue
423     writing to the old log file as long as it holds the file open.
424     Instead, the server must be <a href="stopping.html">restarted</a> after the log files are
425     moved or deleted so that it will open new log files.</p>
426
427     <p>By using a <em>graceful</em> restart, the server can be
428     instructed to open new log files without losing any existing or
429     pending connections from clients. However, in order to
430     accomplish this, the server must continue to write to the old
431     log files while it finishes serving old requests. It is
432     therefore necessary to wait for some time after the restart
433     before doing any processing on the log files. A typical
434     scenario that simply rotates the logs and compresses the old
435     logs to save space is:</p>
436
437     <div class="example"><p><code>
438       mv access_log access_log.old<br />
439       mv error_log error_log.old<br />
440       apachectl graceful<br />
441       sleep 600<br />
442       gzip access_log.old error_log.old
443     </code></p></div>
444
445     <p>Another way to perform log rotation is using <a href="#piped">piped logs</a> as discussed in the next
446     section.</p>
447   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
448 <div class="section">
449 <h2><a name="piped" id="piped">Piped Logs</a></h2>
450     
451     
452     <p>Apache httpd is capable of writing error and access log
453     files through a pipe to another process, rather than directly
454     to a file. This capability dramatically increases the
455     flexibility of logging, without adding code to the main server.
456     In order to write logs to a pipe, simply replace the filename
457     with the pipe character "<code>|</code>", followed by the name
458     of the executable which should accept log entries on its
459     standard input. Apache will start the piped-log process when
460     the server starts, and will restart it if it crashes while the
461     server is running. (This last feature is why we can refer to
462     this technique as "reliable piped logging".)</p>
463
464     <p>Piped log processes are spawned by the parent Apache httpd
465     process, and inherit the userid of that process. This means
466     that piped log programs usually run as root. It is therefore
467     very important to keep the programs simple and secure.</p>
468
469     <p>One important use of piped logs is to allow log rotation
470     without having to restart the server. The Apache HTTP Server
471     includes a simple program called <a href="programs/rotatelogs.html">rotatelogs</a> for this
472     purpose. For example, to rotate the logs every 24 hours, you
473     can use:</p>
474
475     <div class="example"><p><code>
476       CustomLog "|/usr/local/apache/bin/rotatelogs
477       /var/log/access_log 86400" common
478     </code></p></div>
479     
480     <p>Notice that quotes are used to enclose the entire command
481     that will be called for the pipe. Although these examples are
482     for the access log, the same technique can be used for the
483     error log.</p>
484
485     <p>A similar but much more flexible log rotation program
486     called <a href="http://www.cronolog.org/">cronolog</a>
487     is available at an external site.</p>
488
489     <p>As with conditional logging, piped logs are a very powerful
490     tool, but they should not be used where a simpler solution like
491     off-line post-processing is available.</p>
492   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
493 <div class="section">
494 <h2><a name="virtualhost" id="virtualhost">Virtual Hosts</a></h2>
495     
496     
497     <p>When running a server with many <a href="vhosts/">virtual
498     hosts</a>, there are several options for dealing with log
499     files. First, it is possible to use logs exactly as in a
500     single-host server. Simply by placing the logging directives
501     outside the <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> sections in the
502     main server context, it is possible to log all requests in the
503     same access log and error log. This technique does not allow
504     for easy collection of statistics on individual virtual
505     hosts.</p>
506
507     <p>If <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code> 
508     or <code class="directive"><a href="./mod/core.html#errorlog">ErrorLog</a></code>
509     directives are placed inside a
510     <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>
511     section, all requests or errors for that virtual host will be
512     logged only to the specified file. Any virtual host which does
513     not have logging directives will still have its requests sent
514     to the main server logs. This technique is very useful for a
515     small number of virtual hosts, but if the number of hosts is
516     very large, it can be complicated to manage. In addition, it
517     can often create problems with <a href="vhosts/fd-limits.html">insufficient file
518     descriptors</a>.</p>
519
520     <p>For the access log, there is a very good compromise. By
521     adding information on the virtual host to the log format
522     string, it is possible to log all hosts to the same log, and
523     later split the log into individual files. For example,
524     consider the following directives.</p>
525
526     <div class="example"><p><code>
527       LogFormat "%v %l %u %t \"%r\" %&gt;s %b"
528       comonvhost<br />
529       CustomLog logs/access_log comonvhost
530     </code></p></div>
531
532     <p>The <code>%v</code> is used to log the name of the virtual
533     host that is serving the request. Then a program like <a href="programs/other.html">split-logfile</a> can be used to
534     post-process the access log in order to split it into one file
535     per virtual host.</p>
536   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
537 <div class="section">
538 <h2><a name="other" id="other">Other Log Files</a></h2>
539     
540     
541     <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="./mod/mod_cgi.html">mod_cgi</a></code></li><li><code class="module"><a href="./mod/mod_rewrite.html">mod_rewrite</a></code></li></ul></td><td><ul><li><code class="directive"><a href="./mod/mpm_common.html#pidfile">PidFile</a></code></li><li><code class="directive"><a href="./mod/mod_rewrite.html#rewritelog">RewriteLog</a></code></li><li><code class="directive"><a href="./mod/mod_rewrite.html#rewriteloglevel">RewriteLogLevel</a></code></li><li><code class="directive"><a href="./mod/mod_cgi.html#scriptlog">ScriptLog</a></code></li><li><code class="directive"><a href="./mod/mod_cgi.html#scriptlogbuffer">ScriptLogBuffer</a></code></li><li><code class="directive"><a href="./mod/mod_cgi.html#scriptloglength">ScriptLogLength</a></code></li></ul></td></tr></table>
542     
543     <h3><a name="pidfile" id="pidfile">PID File</a></h3>
544       
545     
546       <p>On startup, Apache httpd saves the process id of the parent
547       httpd process to the file <code>logs/httpd.pid</code>. This
548       filename can be changed with the <code class="directive"><a href="./mod/mpm_common.html#pidfile">PidFile</a></code> directive. The
549       process-id is for use by the administrator in restarting and
550       terminating the daemon by sending signals to the parent
551       process; on Windows, use the -k command line option instead.
552       For more information see the <a href="stopping.html">Stopping
553       and Restarting</a> page.</p>    
554     
555     
556     <h3><a name="scriptlog" id="scriptlog">Script Log</a></h3>
557       
558       
559       <p>In order to aid in debugging, the
560       <code class="directive"><a href="./mod/mod_cgi.html#scriptlog">ScriptLog</a></code> directive
561       allows you to record the input to and output from CGI scripts.
562       This should only be used in testing - not for live servers.
563       More information is available in the <a href="mod/mod_cgi.html">mod_cgi</a> documentation.</p>
564     
565     
566     <h3><a name="rewritelog" id="rewritelog">Rewrite Log</a></h3>
567       
568       
569       <p>When using the powerful and complex features of <a href="mod/mod_rewrite.html">mod_rewrite</a>, it is almost
570       always necessary to use the <code class="directive"><a href="./mod/mod_rewrite.html#rewritelog">RewriteLog</a></code> to help
571       in debugging. This log file produces a detailed analysis of how
572       the rewriting engine transforms requests. The level of detail
573       is controlled by the <code class="directive"><a href="./mod/mod_rewrite.html#rewriteloglevel">RewriteLogLevel</a></code> directive.</p>
574     
575   </div></div>
576 <div class="bottomlang">
577 <p><span>Available Languages: </span><a href="./en/logs.html" title="English">&nbsp;en&nbsp;</a> |
578 <a href="./ja/logs.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
579 <a href="./ko/logs.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
580 </div><div id="footer">
581 <p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
582 <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>
583 </body></html>