Logging for multiple sites

Marcus Smith marcussmith at britarch.ac.uk
Wed Nov 26 11:54:30 CET 2008


Dear list,

I currently have a machine running Varnish (2.0.2) set up in front of
several different websites.  I would like to be able to collect access
logs for each of the different sites separately.

Obviously the Apache logs for these sites will be incomplete, as
varnishd will serve cache hits without passing them on.  With a single
instance of varnishd handling all the sites, varnishncsa outputs to a
single log file with logs for all the sites together.  I would like each
site to be logged to a separate file, in the same way that Apache's
virtual hosts can have their own log files.  What is the recommended way
to achieve this with Varnish?

At first I considered running a separate named instance of varnishd and
varnishncsa for each site, thus:

  varnishd -n example1 -a "www.example1.com example1.com" -f
/path/to/vcl/example1.vcl
  varnishd -n example2 -a "www.example2.com example2.com" -f
/path/to/vcl/example2.vcl
  ...
  varnishncsa -n example1 -D -a -w /path/to/logs/example1.log
  varnishncsa -n example2 -D -a -w /path/to/logs/example2.log
  ...

...but of course this will not work because once the first instance of
varnish for example1.com has bound itself to port 80, the second
instance will not start unless it's on a different port.

So I'm stuck.  How should I be doing this?

Many thanks in advance,
Marcus

-- 
Marcus Smith
Information Officer
The Council for British Archaeology



More information about the varnish-misc mailing list