Recipe 22.11. Using Individual Log Files for Virtual Hosts
22.11.1 Problem
Your virtual hosts are pretty busy, and sorting
out a single log file is getting difficult. How can you give each
virtual host its own log file?
22.11.2 Solution
Alter the
httpd.conf entries for each virtual host so
that they have their own log files:
<VirtualHost *:80>
ServerName www.tuxcomputing.com
ServerAlias tuxcomputing.com *.tuxcomputing.com
DocumentRoot /var/www/tuxcomputing
ErrorLog /var/www/tuxcomputing/logs error_log
AccessLog /var/www/tuxcomputing/logs access_log combined
ServerAdmin admin@tuxcomputing.com
</VirtualHost>
22.11.3 Discussion
Note that the AccessLog specifies a particular log format with the
nickname "combined." There are four
ready-made LogFormat directives in
httpd.conf:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
If these do not please you, you can easily create your own. See
http://localhost/manual/mod/mod_log_config.html
for a complete description of the available variables. This is what
the variables in the "combined"
LogFormat mean:
- %h
-
Remote host
- %l
-
Remote logname, from identd
- %u
-
Remote user
- %t
-
Time
- \"%r
-
First line of request
- \" %>s
-
Status—on redirections, this is the status of the original
request
- %b
-
Bytes sent, excluding HTTP headers
- \"%{Referer}i\"
-
Contents of the Referer line in the HTTP header
- \"%{User-Agent}i\"
-
Contents of the User-agent line in the HTTP
header
22.11.4 See Also
|