[an error occurred while processing this directive]

Apache HTTP Server Version 1.3

Multiple Log Files

It is now possible to specify multiple log files, each with a fully customizable format. This is compatible with existing configurations. Multiple log files are implemented as part of the mod_log_config module which as of Apache 1.2 is the default log module.

Using Multiple Log Files

Multiple log files be created with either the TransferLog or CustomLog directive. These directives can be repeated to create more than one log file (in previous releases, only one logfile could be given per server configuration). The TransferLog directive creates a log file in the standard "common log format", although this can be customized with LogFormat. The syntax of these two directives is the same as for the config log module in previous Apache releases.

The real power of multiple log files come from the ability to create log files in different formats. For example, as well as a CLF transfer log, the server could log the user agent of each client, or the referrer information, or any other aspect of the request, such as the language preferences of the user.

The new CustomLog directive takes both a filename to log to, and a log file format.

Syntax: CustomLog filename "format"
Context: server config, virtual host
Status: base
Module: mod_log_config

The first argument is the filename to log to. This is used exactly like the argument to TransferLog, that is, it is either a file as a full path or relative to the current server root, or |programname. Be aware that anyone who can write to the directory where a log file is written can gain access to the uid that starts the server. See the security tips document for details.

The format argument specifies a format for each line of the log file. The options available for the format are exactly the same as for the argument of the LogFormat directive. If the format includes any spaces (which it will do in almost all cases) it should be enclosed in double quotes.

Use with Virtual Hosts

If a <VirtualHost> section does not contain any TransferLog or CustomLog directives, the logs defined for the main server will be used. If it does contain one or more of these directives, requests serviced by this virtual host will only be logged in the log files defined within its definition, not in any of the main server's log files. See the examples below.


To create a normal (CLF) format log file in logs/access_log, and a log of user agents:
TransferLog logs/access_log
CustomLog   logs/agents     "%{user-agent}i"
To define a CLF transfer log and a referrer log which log all accesses to both the main server and a virtual host:
TransferLog logs/access_log
CustomLog   logs/referer    "%{referer}i"

  DocumentRoot   /whatever
  ServerName     my.virtual.host
Since no TransferLog or CustomLog directives appear inside the <VirtualHost> section, any requests for this virtual host will be logged in the main server's log files. If however the directive
TransferLog logs/vhost_access_log
was added inside the virtual host definition, then accesses to this virtual host will be logged in vhost_access_log file (in common log format), and not in logs/access_log or logs/referer.

Apache HTTP Server Version 1.3

Index The English original manual is here.
このページの情報に関わる、ご質問、お問い合わせは、 japache@infoscience.co.jpまで。

JAPACHE ホームページ