2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
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
14 http://www.apache.org/licenses/LICENSE-2.0
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.
23 <modulesynopsis metafile="mod_log_forensic.xml.meta">
25 <name>mod_log_forensic</name>
26 <description>Forensic Logging of the requests made to the server</description>
27 <status>Extension</status>
28 <sourcefile>mod_log_forensic.c</sourcefile>
29 <identifier>log_forensic_module</identifier>
32 <p>This module provides for forensic logging of client requests.</p>
34 <p>Create the log file using the <directive>ForensicLog</directive>
37 <highlight language="config">
38 ForensicLog logs/forensic_log
41 <p>Logging is done before and after processing a request, so the
42 forensic log contains two log lines for each request.
43 The forensic logger is very strict, which means:</p>
46 <li>The format is fixed. You cannot modify the logging format at
48 <li>If it cannot write its data, the child process
49 exits immediately and may dump core (depending on your
50 <directive module="mpm_common">CoreDumpDirectory</directive>
54 <p>The <code>check_forensic</code> script, which can be found in the
55 distribution's support directory, processes the resulting log file
56 to identify the requests that didn't complete.</p>
59 check-forensic forensic_log
62 <seealso><a href="../logs.html">Apache Log Files</a></seealso>
63 <seealso><module>mod_log_config</module></seealso>
65 <section id="formats"><title>Forensic Log Format</title>
66 <p>Each request is logged two times. The first time is <em>before</em> it's
67 processed further (that is, after receiving the headers). The second log
68 entry is written <em>after</em> the request processing at the same time
69 where normal logging occurs.</p>
71 <p>In order to identify each request, a unique request ID is assigned.
72 This forensic ID can be cross logged in the normal transfer log using the
73 <code>%{forensic-id}n</code> format string. If you're using
74 <module>mod_unique_id</module>, its generated ID will be used.</p>
76 <p>The first line logs the forensic ID, the request line and all received
77 headers, separated by pipe characters (<code>|</code>). A sample line
78 looks like the following (all on one line):</p>
81 +yQtJf8CoAB4AAFNXBIEAAAAA|GET /manual/de/images/down.gif
82 HTTP/1.1|Host:localhost%3a8080|User-Agent:Mozilla/5.0 (X11;
83 U; Linux i686; en-US; rv%3a1.6) Gecko/20040216
84 Firefox/0.8|Accept:image/png, <var>etc...</var>
87 <p>The plus character at the beginning indicates that this is the first log
88 line of this request. The second line just contains a minus character and
92 -yQtJf8CoAB4AAFNXBIEAAAAA
95 <p>The <code>check_forensic</code> script takes as its argument the name
96 of the logfile. It looks for those <code>+</code>/<code>-</code> ID pairs
97 and complains if a request was not completed.</p>
100 <section id="security"><title>Security Considerations</title>
102 href="../misc/security_tips.html#serverroot">security tips</a>
103 document for details on why your security could be compromised
104 if the directory where logfiles are stored is writable by
105 anyone other than the user that starts the server.</p>
106 <p>The log files may contain sensitive data such as the contents of
107 <code>Authorization:</code> headers (which can contain passwords), so
108 they should not be readable by anyone except the user that starts the
113 <name>ForensicLog</name>
114 <description>Sets filename of the forensic log</description>
115 <syntax>ForensicLog <var>filename</var>|<var>pipe</var></syntax>
116 <contextlist><context>server config</context><context>virtual host</context>
120 <p>The <directive>ForensicLog</directive> directive is used to
121 log requests to the server for forensic analysis. Each log entry
122 is assigned a unique ID which can be associated with the request
123 using the normal <directive module="mod_log_config">CustomLog</directive>
124 directive. <module>mod_log_forensic</module> creates a token called
125 <code>forensic-id</code>, which can be added to the transfer log
126 using the <code>%{forensic-id}n</code> format string.</p>
128 <p>The argument, which specifies the location to which
129 the logs will be written, can take one of the following two
133 <dt><var>filename</var></dt>
134 <dd>A filename, relative to the <directive module="core"
135 >ServerRoot</directive>.</dd>
137 <dt><var>pipe</var></dt>
138 <dd>The pipe character "<code>|</code>", followed by the path
139 to a program to receive the log information on its standard
140 input. The program name can be specified relative to the <directive
141 module="core">ServerRoot</directive> directive.
143 <note type="warning"><title>Security:</title>
144 <p>If a program is used, then it will be run as the user who
145 started <program>httpd</program>. This will be root if the server was
146 started by root; be sure that the program is secure or switches to a
147 less privileged user.</p>
150 <note><title>Note</title>
151 <p>When entering a file path on non-Unix platforms, care should be taken
152 to make sure that only forward slashes are used even though the platform
153 may allow the use of back slashes. In general it is a good idea to always
154 use forward slashes throughout the configuration files.</p>