1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Apache Multiple Log Files</TITLE>
</HEAD>
<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
<BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#000080"
ALINK="#FF0000"
>
<DIV ALIGN="CENTER">
<IMG SRC="images/sub.gif" ALT="[APACHE DOCUMENTATION]">
<H3>
Apache HTTP Server Version 1.2
</H3>
</DIV>
<h1 ALIGN="CENTER">Multiple Log Files</h1>
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 <a
href="mod/mod_log_config.html">mod_log_config</a> module which as of
Apache 1.2 is the default log module.
<hr>
<h2>Using Multiple Log Files</h2>
Multiple log files be created with either the <code>TransferLog</code>
or <code>CustomLog</code> 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 <code>TransferLog</code> directive creates a log file
in the standard "common log format", although this can be customized
with <code>LogFormat</code>. The syntax of these two
directives is the same as for the config log module in previous
Apache releases.
<p>
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.
<p>
The new <code>CustomLog</code> directive takes both a filename to log
to, and a log file format.
<hr>
<strong>Syntax:</strong> CustomLog <em>filename "format"</em><br>
<strong>Context:</strong> server config, virtual host<br>
<strong>Status:</strong> base<br>
<strong>Module:</strong> mod_log_config<p>
The first argument is the filename to log to. This is used
exactly like the argument to <code>TransferLog</code>, 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 <A HREF="misc/security_tips.html">
security tips</A> document for details.<p>
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 <code>LogFormat</code> directive. If the format
includes any spaces (which it will do in almost all cases) it
should be enclosed in double quotes.
<p>
<h3>Use with Virtual Hosts</h3>
If a <VirtualHost> section does not contain any
<code>TransferLog</code> or <code>CustomLog</code> 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.
<p>
<hr>
<h3>Examples</h3>
To create a normal (CLF) format log file in logs/access_log, and a
log of user agents:
<pre>
TransferLog logs/access_log
CustomLog logs/agents "%{user-agent}i"
</pre>
To define a CLF transfer log and a referrer log which log
all accesses to both the main server and a virtual host:
<pre>
TransferLog logs/access_log
CustomLog logs/referer "%{referer}i"
<VirtualHost>
DocumentRoot /whatever
ServerName my.virtual.host
</VirtualHost>
</pre>
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
<pre>
TransferLog logs/vhost_access_log
</pre>
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 <i>not</i> in logs/access_log or logs/referer.
<HR>
<H3 ALIGN="CENTER">
Apache HTTP Server Version 1.2
</H3>
<A HREF="./"><IMG SRC="images/index.gif" ALT="Index"></A>
</BODY>
</HTML>
|