home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2004 March / PCWMAR04.iso / Software / Resources / Apache / apache_2.0.48-win32-x86-no_ssl.exe / F254350_mod_negotiation.xml.ja < prev    next >
Encoding:
Text File  |  2003-04-15  |  11.0 KB  |  272 lines

  1. s.html">Apache Log Files</a></seealso>
  2.  
  3. <section id="formats"><title>Custom Log Formats</title>
  4.  
  5.     <p>The format argument to the <directive module="mod_log_config"
  6.     >LogFormat</directive> and <directive module="mod_log_config"
  7.     >CustomLog</directive> directives is a string. This string is
  8.     used to log each request to the log file. It can contain literal
  9.     characters copied into the log files and the C-style control
  10.     characters "\n" and "\t" to represent new-lines and tabs.
  11.     Literal quotes and back-slashes should be escaped with
  12.     back-slashes.</p>
  13.  
  14.     <p>The characteristics of the request itself are logged by
  15.     placing "<code>%</code>" directives in the format string, which are
  16.     replaced in the log file by the values as follows:</p>
  17.  
  18.     <table border="1" style="zebra">
  19.     <columnspec><column width=".2"/><column width=".8"/></columnspec>
  20.     <tr><th>Format String</th>
  21.         <th>Description</th></tr>
  22.  
  23.     <tr><td><code>%%</code></td>
  24.         <td>The percent sign (<em>Apache 2.0.44 and later</em>)</td></tr>
  25.  
  26.     <tr><td><code>%...a</code></td>
  27.         <td>Remote IP-address</td></tr>
  28.  
  29.     <tr><td><code>%...A</code></td>
  30.         <td>Local IP-address</td></tr>
  31.  
  32.     <tr><td><code>%...B</code></td>
  33.         <td>Bytes sent, excluding HTTP headers.</td></tr>
  34.  
  35.     <tr><td><code>%...b</code></td>
  36.         <td>Bytes sent, excluding HTTP headers. In CLF format, <em>i.e.</em>
  37.         a '<code>-</code>' rather than a 0 when no bytes are sent.</td></tr>
  38.  
  39.     <tr><td><code>%...{<var>Foobar</var>}C</code></td>
  40.         <td>The contents of cookie <var>Foobar</var> in the request sent
  41.         to the server.</td></tr>
  42.  
  43.     <tr><td><code>%...D</code></td>
  44.         <td>The time taken to serve the request, in microseconds.</td></tr>
  45.  
  46.     <tr><td><code>%...{<var>FOOBAR</var>}e</code></td>
  47.         <td>The contents of the environment variable
  48.         <var>FOOBAR</var></td></tr>
  49.  
  50.     <tr><td><code>%...f</code></td>
  51.         <td>Filename</td></tr>
  52.  
  53.     <tr><td><code>%...h</code></td>
  54.         <td>Remote host</td></tr>
  55.  
  56.     <tr><td><code>%...H</code></td>
  57.         <td>The request protocol</td></tr>
  58.  
  59.     <tr><td><code>%...{<var>Foobar</var>}i</code></td>
  60.         <td>The contents of <code><var>Foobar</var>:</code> header line(s)
  61.         in the request sent to the server.</td></tr>
  62.  
  63.     <tr><td><code>%...l</code></td>
  64.         <td>Remote logname (from identd, if supplied)</td></tr>
  65.  
  66.     <tr><td><code>%...m</code></td>
  67.         <td>The request method</td></tr>
  68.  
  69.     <tr><td><code>%...{<var>Foobar</var>}n</code></td>
  70.         <td>The contents of note <var>Foobar</var> from another
  71.         module.</td></tr>
  72.  
  73.     <tr><td><code>%...{<var>Foobar</var>}o</code></td>
  74.         <td>The contents of <code><var>Foobar</var>:</code> header line(s)
  75.         in the reply.</td></tr>
  76.  
  77.     <tr><td><code>%...p</code></td>
  78.         <td>The canonical port of the server serving the request</td></tr>
  79.  
  80.     <tr><td><code>%...P</code></td>
  81.         <td>The process ID of the child that serviced the request.</td></tr>
  82.  
  83.     <tr><td><code>%...{<var>format</var>}P</code></td>
  84.         <td>The process ID or thread id of the child that serviced the 
  85.         request.  Valid formats are <code>pid</code> and <code>tid</code>.
  86.         (<em>Apache 2.0.46 and later</em>)
  87.         </td></tr>
  88.  
  89.     <tr><td><code>%...q</code></td>
  90.         <td>The query string (prepended with a <code>?</code> if a query
  91.         string exists, otherwise an empty string)</td></tr>
  92.  
  93.     <tr><td><code>%...r</code></td>
  94.         <td>First line of request</td></tr>
  95.  
  96.     <tr><td><code>%...s</code></td>
  97.         <td>Status. For requests that got internally redirected, this is
  98.         the status of the *original* request --- <code>%...>s</code>
  99.         for the last.</td></tr>
  100.  
  101.     <tr><td><code>%...t</code></td>
  102.         <td>Time, in common log format time format (standard english
  103.         format)</td></tr>
  104.  
  105.     <tr><td><code>%...{<var>format</var>}t</code></td>
  106.         <td>The time, in the form given by format, which should be in
  107.         <code>strftime(3)</code> format. (potentially localized)</td></tr>
  108.  
  109.     <tr><td><code>%...T</code></td>
  110.         <td>The time taken to serve the request, in seconds.</td></tr>
  111.  
  112.     <tr><td><code>%...u</code></td>
  113.         <td>Remote user (from auth; may be bogus if return status
  114.         (<code>%s</code>) is 401)</td></tr>
  115.  
  116.     <tr><td><code>%...U</code></td>
  117.         <td>The URL path requested, not including any query string.</td></tr>
  118.  
  119.     <tr><td><code>%...v</code></td>
  120.         <td>The canonical <directive module="core">ServerName</directive>
  121.         of the server serving the request.</td></tr>
  122.  
  123.     <tr><td><code>%...V</code></td>
  124.         <td>The server name according to the <directive module="core"
  125.         >UseCanonicalName</directive> setting.</td></tr>
  126.  
  127.     <tr><td><code>%...X</code></td>
  128.         <td>Connection status when response is completed:
  129.  
  130.         <table>
  131.         <columnspec><column width=".2"/><column width=".6"/></columnspec>
  132.         <tr><td><code>X</code> =</td>
  133.             <td>connection aborted before the response completed.</td></tr>
  134.         <tr><td><code>+</code> =</td>
  135.             <td>connection may be kept alive after the response is
  136.             sent.</td></tr>
  137.         <tr><td><code>-</code> = </td>
  138.             <td>connection will be closed after the response is
  139.             sent.</td></tr>
  140.         </table>
  141.  
  142.         <p>(This directive was <code>%...c</code> in late versions of Apache
  143.         1.3, but this conflicted with the historical ssl
  144.         <code>%...{<var>var</var>}c</code> syntax.)</p></td></tr>
  145.  
  146.     <tr><td><code>%...I</code></td>
  147.         <td>Bytes received, including request and headers, cannot be zero.
  148.         You need to enable <module>mod_logio</module> to use this.</td></tr>
  149.  
  150.     <tr><td><code>%...O</code></td>
  151.         <td>Bytes sent, including headers, cannot be zero. You need to
  152.         enable <module>mod_logio</module> to use this.</td></tr>
  153.     </table>
  154.  
  155.     <p>The "<var>...</var>" can be nothing at all (<em>e.g.</em>,
  156.     <code>"%h %u %r %s %b"</code>), or it can indicate conditions for
  157.     inclusion of the item (which will cause it to be replaced with "-" if
  158.     the condition is not met). The forms of condition are a list of
  159.     HTTP status codes, which may or may not be preceded by "!".
  160.     Thus, "%400,501{User-agent}i" logs <code>User-agent:</code> on 400
  161.     errors and 501 errors (Bad Request, Not Implemented) only;
  162.     "%!200,304,302{Referer}i" logs <code>Referer:</code> on all requests
  163.     which did <em>not</em> return some sort of normal status.</p>
  164.  
  165.     <p>Note that in httpd 2.0 versions prior to 2.0.46, no escaping was performed
  166.     on the strings from <code>%...r</code>, <code>%...i</code> and
  167.     <code>%...o</code>. This was mainly to comply with the requirements of
  168.     the Common Log Format. This implied that clients could insert control
  169.     characters into the log, so you had to be quite careful when dealing
  170.     with raw log files.</p>
  171.  
  172.     <p>For security reasons, starting with 2.0.46, non-printable and
  173.     other special characters are escaped mostly by using
  174.     <code>\x<var>hh</var></code> sequences, where <var>hh</var> stands for
  175.     the hexadecimal representation of the raw byte. Exceptions from this
  176.     rule are <code>"</code> and <code>\</code> which are escaped by prepending
  177.     a backslash, and all whitespace characters which are written in their
  178.     C-style notation (<code>\n</code>, <code>\t</code> etc).</p>
  179.  
  180.     <p>Some commonly used log format strings are:</p>
  181.  
  182.     <dl>
  183.       <dt>Common Log Format (CLF)</dt>
  184.       <dd><code>"%h %l %u %t \"%r\" %>s %b"</code></dd>
  185.  
  186.       <dt>Common Log Format with Virtual Host</dt>
  187.       <dd><code>"%v %h %l %u %t \"%r\" %>s %b"</code></dd>
  188.  
  189.       <dt>NCSA extended/combined log format</dt>
  190.       <dd><code>"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
  191.       \"%{User-agent}i\""</code></dd>
  192.  
  193.       <dt>Referer log format</dt>
  194.       <dd><code>"%{Referer}i -> %U"</code></dd>
  195.  
  196.       <dt>Agent (Browser) log format</dt>
  197.       <dd><code>"%{User-agent}i"</code></dd>
  198.     </dl>
  199.  
  200.     <p>Note that the canonical <directive module="core"
  201.     >ServerName</directive> and <directive module="mpm_common"
  202.     >Listen</directive> of the server serving the
  203.     request are used for <code>%v</code> and <code>%p</code>
  204.     respectively. This happens regardless of the <directive
  205.     module="core">UseCanonicalName</directive> setting
  206.     because otherwise log analysis programs would have to duplicate
  207.     the entire vhost matching algorithm in order to decide what
  208.     host really served the request.</p>
  209. </section>
  210.  
  211. <section id="security"><title>Security Considerations</title>
  212.     <p>See the <a
  213.     href="../misc/security_tips.html#serverroot">security tips</a>
  214.     document for details on why your security could be compromised
  215.     if the directory where logfiles are stored is writable by
  216.     anyone other than the user that starts the server.</p>
  217. </section>
  218.  
  219. <directivesynopsis>
  220. <name>CookieLog</name>
  221. <description>Sets filename for the logging of cookies</description>
  222. <syntax>CookieLog <var>filename</var></syntax>
  223. <contextlist><context>server config</context><context>virtual host</context>
  224. </contextlist>
  225. <compatibility>This directive is deprecated.</compatibility>
  226.  
  227. <usage>
  228.     <p>The <directive>CookieLog</directive> directive sets the 
  229.     filename for logging of cookies. The filename is relative to the
  230.     <directive module="core">ServerRoot</directive>. This directive is
  231.     included only for compatibility with <code>mod_cookies</code>,
  232.     and is deprecated.</p>
  233. </usage>
  234. </directivesynopsis>
  235.  
  236. <directivesynopsis>
  237. <name>CustomLog</name>
  238. <description>Sets filename and format of log file</description>
  239. <syntax>CustomLog  <var>file</var>|<var>pipe</var>
  240. <var>format</var>|<var>nickname</var>
  241. [env=[!]<var>environment-variable</var>]</syntax>
  242. <contextlist><context>server config</context><context>virtual host</context>
  243. </contextlist>
  244.  
  245. <usage>
  246.     <p>The <directive>CustomLog</directive> directive is used to
  247.     log requests to the server. A log format is specified, and the
  248.     logging can optionally be made conditional on request
  249.     characteristics using environment variables.</p>
  250.  
  251.     <p>The first argument, which specifies the location to which
  252.     the logs will be written, can take one of the following two
  253.     types of values:</p>
  254.  
  255.     <dl>
  256.       <dt><var>file</var></dt>
  257.       <dd>A filename, relative to the <directive module="core"
  258.       >ServerRoot</directive>.</dd>
  259.  
  260.       <dt><var>pipe</var></dt>
  261.       <dd>The pipe character "<code>|</code>", followed by the path
  262.       to a program to receive the log information on its standard
  263.       input.
  264.  
  265.       <note type="warning"><title>Security:</title>
  266.       <p>If a program is used, then it will be run as the user who
  267.       started httpd. This will be root if the server was started by root;
  268.       be sure that the program is secure.</p>
  269.       </note>
  270.       <note type="warning"><title>Note</title>
  271.         <p>When entering a file path on non-Unix platforms, care should be taken
  272.