<pre class="prettyprint lang-config">SetEnvIf Request_URI \.gif image-request
SetEnvIf Request_URI \.jpg image-request
SetEnvIf Request_URI \.png image-request
-CustomLog logs/access_log common env=!image-request</pre>
+CustomLog "logs/access_log" common env=!image-request</pre>
SetEnvIf Request_URI \.gif image-request
SetEnvIf Request_URI \.jpg image-request
SetEnvIf Request_URI \.png image-request
-CustomLog logs/access_log common env=!image-request
+CustomLog "logs/access_log" common env=!image-request
</highlight>
</section>
follows.</p>
<pre class="prettyprint lang-config">LogFormat "%h %l %u %t \"%r\" %>s %b" common
-CustomLog logs/access_log common</pre>
+CustomLog "logs/access_log" common</pre>
<p>This defines the <em>nickname</em> <code>common</code> and
Log Format. It can be used as follows.</p>
<pre class="prettyprint lang-config">LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
-CustomLog log/access_log combined</pre>
+CustomLog "log/access_log" combined</pre>
<p>This format is exactly the same as the Common Log Format,
to mimic the effects of the <code>ReferLog</code> and <code>AgentLog</code> directives.</p>
<pre class="prettyprint lang-config">LogFormat "%h %l %u %t \"%r\" %>s %b" common
-CustomLog logs/access_log common
-CustomLog logs/referer_log "%{Referer}i -> %U"
-CustomLog logs/agent_log "%{User-agent}i"</pre>
+CustomLog "logs/access_log" common
+CustomLog "logs/referer_log" "%{Referer}i -> %U"
+CustomLog "logs/agent_log" "%{User-agent}i"</pre>
<p>This example also shows that it is not necessary to define a
# Mark requests for the robots.txt file
SetEnvIf Request_URI "^/robots\.txt$" dontlog
# Log what remains
-CustomLog logs/access_log common env=!dontlog</pre>
+CustomLog "logs/access_log" common env=!dontlog</pre>
<p>As another example, consider logging requests from
english-speakers to one log file, and non-english speakers to a
different log file.</p>
- <pre class="prettyprint lang-config"> SetEnvIf Accept-Language "en" english<br />
- CustomLog logs/english_log common env=english<br />
- CustomLog logs/non_english_log common env=!english</pre>
+ <pre class="prettyprint lang-config">SetEnvIf Accept-Language "en" english<br />
+CustomLog "logs/english_log" common env=english<br />
+CustomLog "logs/non_english_log" common env=!english</pre>
<p>In a caching scenario one would want to know about
<pre class="prettyprint lang-config">SetEnv CACHE_MISS 1
LogFormat "%h %l %u %t "%r " %>s %b %{CACHE_MISS}e" common-cache
-CustomLog logs/access_log common-cache</pre>
+CustomLog "logs/access_log" common-cache</pre>
<p><code class="module"><a href="./mod/mod_cache.html">mod_cache</a></code> will run before
consider the following directives.</p>
<pre class="prettyprint lang-config">LogFormat "%v %l %u %t \"%r\" %>s %b" comonvhost
-CustomLog logs/access_log comonvhost</pre>
+CustomLog "logs/access_log" comonvhost</pre>
<p>The <code>%v</code> is used to log the name of the virtual
<highlight language="config">
LogFormat "%h %l %u %t \"%r\" %>s %b" common
-CustomLog logs/access_log common
+CustomLog "logs/access_log" common
</highlight>
<p>This defines the <em>nickname</em> <code>common</code> and
<highlight language="config">
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
-CustomLog log/access_log combined
+CustomLog "log/access_log" combined
</highlight>
<p>This format is exactly the same as the Common Log Format,
<highlight language="config">
LogFormat "%h %l %u %t \"%r\" %>s %b" common
-CustomLog logs/access_log common
-CustomLog logs/referer_log "%{Referer}i -> %U"
-CustomLog logs/agent_log "%{User-agent}i"
+CustomLog "logs/access_log" common
+CustomLog "logs/referer_log" "%{Referer}i -> %U"
+CustomLog "logs/agent_log" "%{User-agent}i"
</highlight>
<p>This example also shows that it is not necessary to define a
# Mark requests for the robots.txt file
SetEnvIf Request_URI "^/robots\.txt$" dontlog
# Log what remains
-CustomLog logs/access_log common env=!dontlog
+CustomLog "logs/access_log" common env=!dontlog
</highlight>
<p>As another example, consider logging requests from
different log file.</p>
<highlight language="config">
- SetEnvIf Accept-Language "en" english<br />
- CustomLog logs/english_log common env=english<br />
- CustomLog logs/non_english_log common env=!english
+SetEnvIf Accept-Language "en" english<br />
+CustomLog "logs/english_log" common env=english<br />
+CustomLog "logs/non_english_log" common env=!english
</highlight>
<p>In a caching scenario one would want to know about
<highlight language="config">
SetEnv CACHE_MISS 1
LogFormat "%h %l %u %t "%r " %>s %b %{CACHE_MISS}e" common-cache
-CustomLog logs/access_log common-cache
+CustomLog "logs/access_log" common-cache
</highlight>
<p><module>mod_cache</module> will run before
can use:</p>
<highlight language="config">
- CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/access_log 86400" common
+CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/access_log 86400" common
</highlight>
<p>Notice that quotes are used to enclose the entire command
<highlight language="config">
LogFormat "%v %l %u %t \"%r\" %>s %b" comonvhost
-CustomLog logs/access_log comonvhost
+CustomLog "logs/access_log" comonvhost
</highlight>
<p>The <code>%v</code> is used to log the name of the virtual
a pipe character (<code>|</code>). For instance:
</p>
- <div class="example"><p><code>CustomLog "|/usr/local/apache2/bin/rotatelogs
- /var/log/access_log 86400" common
+ <div class="example"><p><code>
+CustomLog "|/usr/local/apache2/bin/rotatelogs /var/log/access_log 86400" common
</code></p></div>
<p>The program on the other end of the pipe will receive the
</Directory>
RewriteLog "/home/sctemme/inst/blog/httpd/logs/rewrite_log"
RewriteLogLevel 9
- ErrorLog /home/sctemme/inst/blog/httpd/logs/error_log
+ ErrorLog "/home/sctemme/inst/blog/httpd/logs/error_log"
LogLevel debug
- CustomLog /home/sctemme/inst/blog/httpd/logs/access_log common
+ CustomLog "/home/sctemme/inst/blog/httpd/logs/access_log" common
ScriptAlias "/cgi-bin/" "/home/sctemme/inst/blog/bin/"
<Directory "/home/sctemme/inst/blog/bin">
Options +ExecCGI
a pipe character (<code>|</code>). For instance:
</p>
- <example>CustomLog "|/usr/local/apache2/bin/rotatelogs
- /var/log/access_log 86400" common
+ <example>
+CustomLog "|/usr/local/apache2/bin/rotatelogs /var/log/access_log 86400" common
</example>
<p>The program on the other end of the pipe will receive the
</Directory>
RewriteLog "/home/sctemme/inst/blog/httpd/logs/rewrite_log"
RewriteLogLevel 9
- ErrorLog /home/sctemme/inst/blog/httpd/logs/error_log
+ ErrorLog "/home/sctemme/inst/blog/httpd/logs/error_log"
LogLevel debug
- CustomLog /home/sctemme/inst/blog/httpd/logs/access_log common
+ CustomLog "/home/sctemme/inst/blog/httpd/logs/access_log" common
ScriptAlias "/cgi-bin/" "/home/sctemme/inst/blog/bin/"
<Directory "/home/sctemme/inst/blog/bin">
Options +ExecCGI
ServerAdmin webmaster@host.example.com
DocumentRoot "/www/docs/host.example.com"
ServerName host.example.com
- ErrorLog logs/host.example.com-error_log
- TransferLog logs/host.example.com-access_log
+ ErrorLog "logs/host.example.com-error_log"
+ TransferLog "logs/host.example.com-access_log"
</VirtualHost></pre>
ServerAdmin webmaster@host.example.com
DocumentRoot "/www/docs/host.example.com"
ServerName host.example.com
- ErrorLog logs/host.example.com-error_log
- TransferLog logs/host.example.com-access_log
+ ErrorLog "logs/host.example.com-error_log"
+ TransferLog "logs/host.example.com-access_log"
</VirtualHost></pre>
ServerAdmin webmaster@host.example.com
DocumentRoot "/www/docs/host.example.com"
ServerName host.example.com
- ErrorLog logs/host.example.com-error_log
- TransferLog logs/host.example.com-access_log
+ ErrorLog "logs/host.example.com-error_log"
+ TransferLog "logs/host.example.com-access_log"
</VirtualHost>
</highlight>
ServerAdmin webmaster@host.example.com
DocumentRoot "/www/docs/host.example.com"
ServerName host.example.com
- ErrorLog logs/host.example.com-error_log
- TransferLog logs/host.example.com-access_log
+ ErrorLog "logs/host.example.com-error_log"
+ TransferLog "logs/host.example.com-access_log"
</VirtualHost>
</highlight>
<p>This makes it possible to support conditional logging of cached requests
as per the following example:</p>
- <pre class="prettyprint lang-config">CustomLog cached-requests.log common env=cache-hit
-CustomLog uncached-requests.log common env=cache-miss
-CustomLog revalidated-requests.log common env=cache-revalidate
-CustomLog invalidated-requests.log common env=cache-invalidate</pre>
+ <pre class="prettyprint lang-config">CustomLog "cached-requests.log" common env=cache-hit
+CustomLog "uncached-requests.log" common env=cache-miss
+CustomLog "revalidated-requests.log" common env=cache-revalidate
+CustomLog "invalidated-requests.log" common env=cache-invalidate</pre>
<p>For module authors, a hook called <var>cache_status</var> is available,
as per the following example:</p>
<highlight language="config">
-CustomLog cached-requests.log common env=cache-hit
-CustomLog uncached-requests.log common env=cache-miss
-CustomLog revalidated-requests.log common env=cache-revalidate
-CustomLog invalidated-requests.log common env=cache-invalidate
+CustomLog "cached-requests.log" common env=cache-hit
+CustomLog "uncached-requests.log" common env=cache-miss
+CustomLog "revalidated-requests.log" common env=cache-revalidate
+CustomLog "invalidated-requests.log" common env=cache-invalidate
</highlight>
<p>For module authors, a hook called <var>cache_status</var> is available,
<div class="example"><h3>Example</h3><pre class="prettyprint lang-config"> DeflateFilterNote ratio
LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
- CustomLog logs/deflate_log deflate</pre>
+ CustomLog "logs/deflate_log" deflate</pre>
</div>
<p>If you want to extract more accurate values from your logs, you
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
-CustomLog logs/deflate_log deflate</pre>
+CustomLog "logs/deflate_log" deflate</pre>
</div>
<h3>See also</h3>
DeflateFilterNote ratio
LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
- CustomLog logs/deflate_log deflate
+ CustomLog "logs/deflate_log" deflate
</highlight>
</example>
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
-CustomLog logs/deflate_log deflate
+CustomLog "logs/deflate_log" deflate
</highlight>
</example>
</usage>
<pre class="prettyprint lang-config"># CustomLog with format nickname
LogFormat "%h %l %u %t \"%r\" %>s %b" common
-CustomLog logs/access_log common
+CustomLog "logs/access_log" common
# CustomLog with explicit format string
-CustomLog logs/access_log "%h %l %u %t \"%r\" %>s %b"</pre>
+CustomLog "logs/access_log" "%h %l %u %t \"%r\" %>s %b"</pre>
<p>The third argument is optional and controls whether or
log, you can use:</p>
<pre class="prettyprint lang-config">SetEnvIf Request_URI \.gif$ gif-image
-CustomLog gif-requests.log common env=gif-image
-CustomLog nongif-requests.log common env=!gif-image</pre>
+CustomLog "gif-requests.log" common env=gif-image
+CustomLog "nongif-requests.log" common env=!gif-image</pre>
<p>Or, to reproduce the behavior of the old RefererIgnore
directive, you might use the following:</p>
<pre class="prettyprint lang-config">SetEnvIf Referer example\.com localreferer
-CustomLog referer.log referer env=!localreferer</pre>
+CustomLog "referer.log" referer env=!localreferer</pre>
</div>
other format has been specified.</p>
<div class="example"><h3>Example</h3><pre class="prettyprint lang-config">LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
-TransferLog logs/access_log</pre>
+TransferLog "logs/access_log"</pre>
</div>
</div>
<highlight language="config">
# CustomLog with format nickname
LogFormat "%h %l %u %t \"%r\" %>s %b" common
-CustomLog logs/access_log common
+CustomLog "logs/access_log" common
# CustomLog with explicit format string
-CustomLog logs/access_log "%h %l %u %t \"%r\" %>s %b"
+CustomLog "logs/access_log" "%h %l %u %t \"%r\" %>s %b"
</highlight>
<p>The third argument is optional and controls whether or
<highlight language="config">
SetEnvIf Request_URI \.gif$ gif-image
-CustomLog gif-requests.log common env=gif-image
-CustomLog nongif-requests.log common env=!gif-image
+CustomLog "gif-requests.log" common env=gif-image
+CustomLog "nongif-requests.log" common env=!gif-image
</highlight>
<p>Or, to reproduce the behavior of the old RefererIgnore
<highlight language="config">
SetEnvIf Referer example\.com localreferer
-CustomLog referer.log referer env=!localreferer
+CustomLog "referer.log" referer env=!localreferer
</highlight>
</usage>
</directivesynopsis>
<example><title>Example</title>
<highlight language="config">
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
-TransferLog logs/access_log
+TransferLog "logs/access_log"
</highlight>
</example>
</usage>
ServerAlias www.$domain
DocumentRoot "/var/www/vhosts/$name"
- ErrorLog /var/log/httpd/$name.error_log
- CustomLog /var/log/httpd/$name.access_log combined
+ ErrorLog "/var/log/httpd/$name.error_log"
+ CustomLog "/var/log/httpd/$name.access_log" combined
</VirtualHost>
</Macro></pre>
ServerAlias www.$domain
DocumentRoot "/var/www/vhosts/$name"
- ErrorLog /var/log/httpd/$name.error_log
- CustomLog /var/log/httpd/$name.access_log combined
+ ErrorLog "/var/log/httpd/$name.error_log"
+ CustomLog "/var/log/httpd/$name.access_log" combined
</VirtualHost>
</Macro>
</highlight>
For backward compatibility there is additionally a special
``<code>%{</code><em>name</em><code>}c</code>'' cryptography format function
provided. Information about this function is provided in the <a href="../ssl/ssl_compat.html">Compatibility</a> chapter.</p>
-<div class="example"><h3>Example</h3><pre class="prettyprint lang-config">CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"</pre>
+<div class="example"><h3>Example</h3><pre class="prettyprint lang-config">CustomLog "logs/ssl_request_log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"</pre>
</div>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
href="../ssl/ssl_compat.html">Compatibility</a> chapter.</p>
<example><title>Example</title>
<highlight language="config">
-CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
+CustomLog "logs/ssl_request_log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</highlight>
</example>
</section>
via <code class="module"><a href="../mod/mod_log_config.html">mod_log_config</a></code> configurable logging formats:</p>
<pre class="prettyprint lang-config">LogFormat "%{Apache}n %r %t" usertrack
-CustomLog logs/clickstream.log usertrack</pre>
+CustomLog "logs/clickstream.log" usertrack</pre>
</div>
<highlight language="config">
LogFormat "%{Apache}n %r %t" usertrack
-CustomLog logs/clickstream.log usertrack
+CustomLog "logs/clickstream.log" usertrack
</highlight>
</section>
<p>Create a log file with virtual host information in it:</p>
<pre class="prettyprint lang-config">LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined_plus_vhost
-CustomLog logs/access_log combined_plus_vhost</pre>
+CustomLog "logs/access_log" combined_plus_vhost</pre>
<p>Log files will be created, in the directory where you run the
<highlight language="config">
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined_plus_vhost
-CustomLog logs/access_log combined_plus_vhost
+CustomLog "logs/access_log" combined_plus_vhost
</highlight>
<p>Log files will be created, in the directory where you run the
log.</p>
<pre class="prettyprint lang-config">RewriteRule "\.(png|gif|jpg)$" "-" [E=image:1]
-CustomLog logs/access_log combined env=!image</pre>
+CustomLog "logs/access_log" combined env=!image</pre>
<p>Note that this same effect can be obtained using <code class="directive"><a href="../mod/mod_setenvif.html#setenvif">SetEnvIf</a></code>. This technique is offered as
<highlight language="config">
RewriteRule "\.(png|gif|jpg)$" "-" [E=image:1]
-CustomLog logs/access_log combined env=!image
+CustomLog "logs/access_log" combined env=!image
</highlight>
<p>Note that this same effect can be obtained using <directive
# splittable logs
LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
<Directory "/www/hosts">
# ExecCGI is needed here because we can't force
# splittable logs
LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
<Directory "/www/hosts">
# ExecCGI is needed here because we can't force
of your log format string:</p>
<pre class="prettyprint lang-config">LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost
-CustomLog logs/multiple_vhost_log vhost</pre>
+CustomLog "logs/multiple_vhost_log" vhost</pre>
<p>This will create a log file in the common log format, but with the
<highlight language="config">
LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost
-CustomLog logs/multiple_vhost_log vhost
+CustomLog "logs/multiple_vhost_log" vhost
</highlight>
<p>This will create a log file in the common log format, but with the
# this log format can be split per-virtual-host based on the first field
# using the split-logfile utility.
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot "/www/hosts/%0/docs"
<pre class="prettyprint lang-config">UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
# include part of the server name in the filenames
VirtualDocumentRoot "/home/%2/www"
<VirtualHost 111.22.33.44>
ServerName www.commercial.example.com
- CustomLog logs/access_log.commercial vcommon
+ CustomLog "logs/access_log.commercial" vcommon
VirtualDocumentRoot "/www/commercial/%0/docs"
VirtualScriptAlias "/www/commercial/%0/cgi-bin"
<VirtualHost 111.22.33.45>
ServerName www.homepages.example.com
- CustomLog logs/access_log.homepages vcommon
+ CustomLog "logs/access_log.homepages" vcommon
VirtualDocumentRoot "/www/homepages/%0/docs"
ScriptAlias "/cgi-bin/" "/www/std-cgi/"
# include the IP address in the logs so they may be split
LogFormat "%A %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
# include the IP address in the filenames
VirtualDocumentRootIP "/www/hosts/%0/docs"
# this log format can be split per-virtual-host based on the first field
# using the split-logfile utility.
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot "/www/hosts/%0/docs"
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
# include part of the server name in the filenames
VirtualDocumentRoot "/home/%2/www"
<VirtualHost 111.22.33.44>
ServerName www.commercial.example.com
- CustomLog logs/access_log.commercial vcommon
+ CustomLog "logs/access_log.commercial" vcommon
VirtualDocumentRoot "/www/commercial/%0/docs"
VirtualScriptAlias "/www/commercial/%0/cgi-bin"
<VirtualHost 111.22.33.45>
ServerName www.homepages.example.com
- CustomLog logs/access_log.homepages vcommon
+ CustomLog "logs/access_log.homepages" vcommon
VirtualDocumentRoot "/www/homepages/%0/docs"
ScriptAlias "/cgi-bin/" "/www/std-cgi/"
# include the IP address in the logs so they may be split
LogFormat "%A %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
# include the IP address in the filenames
VirtualDocumentRootIP "/www/hosts/%0/docs"