Forum Moderators: phranque
we're just setting up our redhat / apache server with virtual hosts. i am about to install the webalizer-rpm so that each client can see their own stats.
at the moment all virtual hosts log to the same log files:
TransferLog logs/access_log
ErrorLog logs/error_log
can i leave it like that and simply install webalizer and webalizer will sort out which parts of which logs go with each virtual host?
or will i need to manually add the following to httpd.conf
LogFormat "%v %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
CustomLog logs/access_log combined
many thanks :)
p.s. why exactly is the CustomLog directive needed? is that to combine all of the above LogFormats?
If you have many you will probably have to have a single log file, which you them split before running webalizer for each site.
In that case you need a directive like
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T %v" full
The last %v inserts the name of the virtual host in the log entry.
Then make a single log file for all sites with
CustomLog /var/log/apache/custom.log full
in the global part of httpd.conf.
Then use a script like the following to split the log file into separate files, one for each vhost.
--------------------------
#!/usr/bin/perl -w
use strict;
use warnings;
-d 'logs' or mkdir 'logs';
my %fds;
while (<>[smilestopper]) {
chomp;
my @x = split;
my $site = pop @x;
my $fd = $fds{$site};
unless (defined $fd) {
#print STDERR "OPEN $site\n";
open($fd, ">>logs/$site"[smilestopper]) or next;
$fds{$site} = $fd;
}
print $fd "$_\n";
}
-------------
after this the logs directory contains several files, one for each vhost. Feed these to webalizer.
René.
thanks for the tip. i did it and it installed webalizer and apache-1.3.27-1.7.2.i386.rpm as well.
when i did a search for 'webserver' at rpmfind it returned exactly this apache package, but i know we already had apache installed and i didn't want to touch that.
but obviously the system knows best :-)
i guess its me coming from windows background where installing and uninstalling is rather inaccurate science ;-)
now i can get on splitting and combining the logs rené.
i'll get back to you if i run into trouble
thanks both!