⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logs.html.en

📁 最新apache的源代码
💻 EN
📖 第 1 页 / 共 3 页
字号:
        SetEnvIf Request_URI "^/robots\.txt$" dontlog<br />        # Log what remains<br />        CustomLog logs/access_log common env=!dontlog      </code></p></div>      <p>As another example, consider logging requests from      english-speakers to one log file, and non-english speakers to a      different log file.</p>      <div class="example"><p><code>        SetEnvIf Accept-Language "en" english<br />        CustomLog logs/english_log common env=english<br />        CustomLog logs/non_english_log common env=!english      </code></p></div>      <p>Although we have just shown that conditional logging is very      powerful and flexible, it is not the only way to control the      contents of the logs. Log files are more useful when they      contain a complete record of server activity. It is often      easier to simply post-process the log files to remove requests      that you do not want to consider.</p>      </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="rotation" id="rotation">Log Rotation</a></h2>        <p>On even a moderately busy server, the quantity of    information stored in the log files is very large. The access    log file typically grows 1 MB or more per 10,000 requests. It    will consequently be necessary to periodically rotate the log    files by moving or deleting the existing logs. This cannot be    done while the server is running, because Apache will continue    writing to the old log file as long as it holds the file open.    Instead, the server must be <a href="stopping.html">restarted</a> after the log files are    moved or deleted so that it will open new log files.</p>    <p>By using a <em>graceful</em> restart, the server can be    instructed to open new log files without losing any existing or    pending connections from clients. However, in order to    accomplish this, the server must continue to write to the old    log files while it finishes serving old requests. It is    therefore necessary to wait for some time after the restart    before doing any processing on the log files. A typical    scenario that simply rotates the logs and compresses the old    logs to save space is:</p>    <div class="example"><p><code>      mv access_log access_log.old<br />      mv error_log error_log.old<br />      apachectl graceful<br />      sleep 600<br />      gzip access_log.old error_log.old    </code></p></div>    <p>Another way to perform log rotation is using <a href="#piped">piped logs</a> as discussed in the next    section.</p>  </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="piped" id="piped">Piped Logs</a></h2>        <p>Apache httpd is capable of writing error and access log    files through a pipe to another process, rather than directly    to a file. This capability dramatically increases the    flexibility of logging, without adding code to the main server.    In order to write logs to a pipe, simply replace the filename    with the pipe character "<code>|</code>", followed by the name    of the executable which should accept log entries on its    standard input. Apache will start the piped-log process when    the server starts, and will restart it if it crashes while the    server is running. (This last feature is why we can refer to    this technique as "reliable piped logging".)</p>    <p>Piped log processes are spawned by the parent Apache httpd    process, and inherit the userid of that process. This means    that piped log programs usually run as root. It is therefore    very important to keep the programs simple and secure.</p>    <p>One important use of piped logs is to allow log rotation    without having to restart the server. The Apache HTTP Server    includes a simple program called <code class="program"><a href="./programs/rotatelogs.html">rotatelogs</a></code>    for this purpose. For example, to rotate the logs every 24 hours, you    can use:</p>    <div class="example"><p><code>      CustomLog "|/usr/local/apache/bin/rotatelogs      /var/log/access_log 86400" common    </code></p></div>    <p>Notice that quotes are used to enclose the entire command    that will be called for the pipe. Although these examples are    for the access log, the same technique can be used for the    error log.</p>    <p>A similar but much more flexible log rotation program    called <a href="http://www.cronolog.org/">cronolog</a>    is available at an external site.</p>    <p>As with conditional logging, piped logs are a very powerful    tool, but they should not be used where a simpler solution like    off-line post-processing is available.</p>  </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="virtualhost" id="virtualhost">Virtual Hosts</a></h2>        <p>When running a server with many <a href="vhosts/">virtual    hosts</a>, there are several options for dealing with log    files. First, it is possible to use logs exactly as in a    single-host server. Simply by placing the logging directives    outside the <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> sections in the    main server context, it is possible to log all requests in the    same access log and error log. This technique does not allow    for easy collection of statistics on individual virtual    hosts.</p>    <p>If <code class="directive"><a href="./mod/mod_log_config.html#customlog">CustomLog</a></code>     or <code class="directive"><a href="./mod/core.html#errorlog">ErrorLog</a></code>    directives are placed inside a    <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>    section, all requests or errors for that virtual host will be    logged only to the specified file. Any virtual host which does    not have logging directives will still have its requests sent    to the main server logs. This technique is very useful for a    small number of virtual hosts, but if the number of hosts is    very large, it can be complicated to manage. In addition, it    can often create problems with <a href="vhosts/fd-limits.html">insufficient file    descriptors</a>.</p>    <p>For the access log, there is a very good compromise. By    adding information on the virtual host to the log format    string, it is possible to log all hosts to the same log, and    later split the log into individual files. For example,    consider the following directives.</p>    <div class="example"><p><code>      LogFormat "%v %l %u %t \"%r\" %&gt;s %b"      comonvhost<br />      CustomLog logs/access_log comonvhost    </code></p></div>    <p>The <code>%v</code> is used to log the name of the virtual    host that is serving the request. Then a program like <a href="programs/other.html">split-logfile</a> can be used to    post-process the access log in order to split it into one file    per virtual host.</p>  </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div><div class="section"><h2><a name="other" id="other">Other Log Files</a></h2>        <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>    <h3><a name="pidfile" id="pidfile">PID File</a></h3>            <p>On startup, Apache httpd saves the process id of the parent      httpd process to the file <code>logs/httpd.pid</code>. This      filename can be changed with the <code class="directive"><a href="./mod/mpm_common.html#pidfile">PidFile</a></code> directive. The      process-id is for use by the administrator in restarting and      terminating the daemon by sending signals to the parent      process; on Windows, use the -k command line option instead.      For more information see the <a href="stopping.html">Stopping      and Restarting</a> page.</p>            <h3><a name="scriptlog" id="scriptlog">Script Log</a></h3>            <p>In order to aid in debugging, the      <code class="directive"><a href="./mod/mod_cgi.html#scriptlog">ScriptLog</a></code> directive      allows you to record the input to and output from CGI scripts.      This should only be used in testing - not for live servers.      More information is available in the <a href="mod/mod_cgi.html">mod_cgi</a> documentation.</p>        <h3><a name="rewritelog" id="rewritelog">Rewrite Log</a></h3>            <p>When using the powerful and complex features of <a href="mod/mod_rewrite.html">mod_rewrite</a>, it is almost      always necessary to use the <code class="directive"><a href="./mod/mod_rewrite.html#rewritelog">RewriteLog</a></code> to help      in debugging. This log file produces a detailed analysis of how      the rewriting engine transforms requests. The level of detail      is controlled by the <code class="directive"><a href="./mod/mod_rewrite.html#rewriteloglevel">RewriteLogLevel</a></code> directive.</p>      </div></div><div class="bottomlang"><p><span>Available Languages: </span><a href="./en/logs.html" title="English">&nbsp;en&nbsp;</a> |<a href="./es/logs.html" hreflang="es" rel="alternate" title="Espa駉l">&nbsp;es&nbsp;</a> |<a href="./ja/logs.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |<a href="./ko/logs.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p></div><div id="footer"><p class="apache">Copyright 1995-2005 The Apache Software Foundation or its licensors, as applicable.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p><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></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -