📄 mod_log_config.html.en
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!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><!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX This file is generated from xml source: DO NOT EDIT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --><title>mod_log_config - Apache HTTP Server</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 href="../images/favicon.ico" rel="shortcut icon" /></head><body><div id="page-header"><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><p class="apache">Apache HTTP Server Version 2.0</p><img alt="" src="../images/feather.gif" /></div><div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div><div id="path"><a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.0</a> > <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"> en </a> |<a href="../ja/mod/mod_log_config.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |<a href="../ko/mod/mod_log_config.html" hreflang="ko" rel="alternate" title="Korean"> ko </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營dentifier:</a></th><td>log_config_module</td></tr><tr><th><a href="module-dict.html#SourceFile">Source燜ile:</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 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="#cookielog">CookieLog</a></li><li><img alt="" src="../images/down.gif" /> <a href="#customlog">CustomLog</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>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>See also</h3><ul class="seealso"><li><a href="../logs.html">Apache Log Files</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></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 back-slashes should be escaped with back-slashes.</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 String</th> <th>Description</th></tr><tr><td><code>%%</code></td> <td>The percent sign (<em>Apache 2.0.44 and later</em>)</td></tr><tr class="odd"><td><code>%...a</code></td> <td>Remote IP-address</td></tr><tr><td><code>%...A</code></td> <td>Local IP-address</td></tr><tr class="odd"><td><code>%...B</code></td> <td>Size of response in bytes, excluding HTTP headers.</td></tr><tr><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 class="odd"><td><code>%...{<var>Foobar</var>}C</code></td> <td>The contents of cookie <var>Foobar</var> in the request sent to the server.</td></tr><tr><td><code>%...D</code></td> <td>The time taken to serve the request, in microseconds.</td></tr><tr class="odd"><td><code>%...{<var>FOOBAR</var>}e</code></td> <td>The contents of the environment variable <var>FOOBAR</var></td></tr><tr><td><code>%...f</code></td> <td>Filename</td></tr><tr class="odd"><td><code>%...h</code></td> <td>Remote host</td></tr><tr><td><code>%...H</code></td> <td>The request protocol</td></tr><tr class="odd"><td><code>%...{<var>Foobar</var>}i</code></td> <td>The contents of <code><var>Foobar</var>:</code> header line(s) in the request sent to the server.</td></tr><tr><td><code>%...l</code></td> <td>Remote logname (from identd, if supplied). This will return a dash unless <code class="directive"><a href="../mod/core.html#identitycheck">IdentityCheck</a></code> is set <code>On</code>.</td></tr><tr class="odd"><td><code>%...m</code></td> <td>The request method</td></tr><tr><td><code>%...{<var>Foobar</var>}n</code></td> <td>The contents of note <var>Foobar</var> from another module.</td></tr><tr class="odd"><td><code>%...{<var>Foobar</var>}o</code></td> <td>The contents of <code><var>Foobar</var>:</code> header line(s) in the reply.</td></tr><tr><td><code>%...p</code></td> <td>The canonical port of the server serving the request</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> and <code>tid</code>. (<em>Apache 2.0.46 and later</em>) </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>%...s</code></td> <td>Status. For requests that got internally redirected, this is the status of the *original* request --- <code>%...>s</code> for the last.</td></tr><tr><td><code>%...t</code></td> <td>Time the request was received (standard english format)</td></tr><tr class="odd"><td><code>%...{<var>format</var>}t</code></td> <td>The time, in the form given by format, which should be in <code>strftime(3)</code> format. (potentially localized)</td></tr><tr><td><code>%...T</code></td> <td>The time taken to serve the request, in seconds.</td></tr><tr class="odd"><td><code>%...u</code></td> <td>Remote user (from auth; may be bogus if return status (<code>%s</code>) is 401)</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> <p>(This directive was <code>%...c</code> in late versions of Apache 1.3, but this conflicted with the historical ssl <code>%...{<var>var</var>}c</code> syntax.)</p></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, 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></table> <p>The "<var>...</var>" can be nothing at all (<em>e.g.</em>, <code>"%h %u %r %s %b"</code>), or it can indicate conditions for inclusion of the item (which will cause it to be replaced with "-" if the condition is not met). The forms of condition are a list of HTTP status codes, which may or may not be preceded by "!". Thus, "%400,501{User-agent}i" logs <code>User-agent:</code> on 400 errors and 501 errors (Bad Request, Not Implemented) only; "%!200,304,302{Referer}i" logs <code>Referer:</code> on all requests which did <em>not</em> return some sort of normal status.</p> <p>The modifiers "<" and ">" 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>%>s</code> can be used to record the final status of the request and <code>%<u</code> can be used to record the original authenticated user on a request that is internally redirected to an unauthenticated resource.</p> <p>Note that in httpd 2.0 versions prior to 2.0.46, no escaping was performed on the strings from <code>%...r</code>, <code>%...i</code> and <code>%...o</code>. This was mainly to comply with the requirements of the Common Log Format. This implied that clients could insert control characters into the log, so you had to be quite careful when dealing with raw log files.</p> <p>For security reasons, starting with 2.0.46, non-printable and other special characters are escaped mostly by 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).</p> <p>Note that in 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> <p>Some commonly used log format strings are:</p> <dl> <dt>Common Log Format (CLF)</dt> <dd><code>"%h %l %u %t \"%r\" %>s %b"</code></dd> <dt>Common Log Format with Virtual Host</dt> <dd><code>"%v %h %l %u %t \"%r\" %>s %b"</code></dd>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -