Apache 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
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).
TransferLog directive creates a log file
in the standard "common log format", although this can be customized
LogFormat. The syntax of these two
directives is the same as for the config log module in previous
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.
CustomLog directive takes both a filename to log
to, and a log file format.
Syntax: CustomLog filename "format"
Context: server config, virtual host
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
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.