HOW-TO
Use Analog for Virtual Hosts
(Using Separate Logfiles)

This HOW-TO written by Peter Rose.
Converted to HTML and Step Three added by Stephen Turner.

One of the great things about Analog is that it can easily be used to offer different customised output to multiple virtual hosts on the same server.

This is an obvious asset if you host several domains on your server and want to offer all your customers the benefit of daily/weekly/monthly Analog stats, but not all of them require the same level of reporting or the same 'look'.

This real-world example is based on Apache 1.3.12 running on RedHat Linux 6.1, but should be applicable to any Unix-like platform. Steps Two and Three, and the general ideas, should be helpful on Windows NT and other operating systems, but for the details you'll have to ask someone else :-)

Step One

Make the necessary entries in the Apache Virtual Host sections.

Here's an example from my httpd.conf:

<VirtualHost 212.87.82.24>
ServerName www.ontiles.com
SSLDisable
DocumentRoot /home/httpd/html/tileshop
ServerAdmin webmaster@ontiles.com
CustomLog logs/ontiles-referer_log  referer
TransferLog logs/ontiles.com-access_log
</VirtualHost>

<VirtualHost 212.87.82.24>
ServerName www.nuw-maas.co.uk
SSLDisable
DocumentRoot /home/httpd/html/nuwmaas
ServerAdmin webmaster@cyberscreen.com
TransferLog logs/nuw-maas-access_log
</VirtualHost>

Here you can see there are 2 virtual hosts with different logging requirements:

ontiles.com wants to get a referer report as well as the regular access statistics, whereas nuw-maas.co.uk only needs the basic access stats.

Step Two

Create a separate analog.cfg file for each domain. It's your choice whether you want each domain's config file to replace or to supplement the global analog.cfg - see Step Four for details.

For ontiles.com, we have a file called (with stunning originality) ontilesanalog.cfg. The relevant parts from this are as follows:

LOGFILE /etc/httpd/logs/ontiles.com-access_log
LOGFORMAT REFERRER
LOGFILE /etc/httpd/logs/ontiles-referer_log
OUTFILE /home/httpd/html/cyberscreen/stats/ontiles_stats.html 
HOSTNAME "ONTILES.COM"
HOSTURL "http://www.ontiles.com/"
IMAGEDIR "http://www.cyberscreen.com/images/"
LOGO "ontileslogo.jpg"
STYLESHEET ontilesanalogstyle.css
Note the order in which the LOGFILE and LOGFORMAT commands appear - if the LOGFORMAT REFERRER is not before the LOGFILE /etc/httpd/logs/ontiles-referer_log, it won't work! You can see also that we're giving the reports for this domain their own logo at the top of the page and are using a stylesheet that will match that of their website. Not essential, but you can't beat the finishing touches :-)

Now here's the same section for the analog.cfg file for the other virtual host - which, yes, you've guessed it, is called nuw-maasanalog.cfg.

LOGFILE /etc/httpd/logs/nuw-maas-access_log
OUTFILE /home/httpd/html/cyberscreen/stats/nuw-maas_stats.html 
HOSTNAME "WWW.NUW-MAAS.CO.UK"
HOSTURL "http://www.nuw-maas.co.uk/"
IMAGEDIR "http://www.cyberscreen.com/images/"
LOGO "nuw-maaslogo.jpg"
STYLESHEET nuw-maassanalogstyle.css
So by this time, you get the idea. This domain don't need the referrer report, but they would like their own groovy logo and stylesheet applied to the output. You can, of course, take the opportunity within each domain's analog.cfg file to tweak the output appearance, request floors and so on according to each host's requirements.

Step Three

We also want a report for our own use with a summary of the usage for all the virtual hosts. So we need to analyse all the logfiles together. The problem is that the filenames appear in the logfiles as just /index.html for example, but we want to see http://www.ontiles.com/index.html, so that we know which files belong to which virtual hosts. This is where the second argument to the LOGFILE command comes in. This argument specifies a prefix to add to the filenames in that logfile. You can see this in this configuration file, which we'll call all.cfg:
LOGFILE /etc/httpd/logs/ontiles.com-access_log http://www.ontiles.com
LO