Virtualhost logging for varnishncsa

Rob Halff rob.halff at
Fri Apr 3 14:49:09 CEST 2009


I've changed the varnishncsa sourcecode to support virtualhost logging.

I know in the TODO of varnishncsa there is a future wish for "Log in
any format one wants",
but I can imagine that would need a total rewrite and takes some time.

So in the meantime I have a request to add the virtualhost logging as
a commandline option.

I've added  a -v flag enabling virtualhost style logging
In this case the logformat looks like:

$ varnishncsa -v 111.222.333.44 - - [03/Apr/2009:11:41:57 +0200] "GET HTTP/1.1" 404 209 "-" "Mozilla/4.0
(compatible; MSIE 7.0; Windows NT 5.1; GTB5)"

Notice the '' being logged.

This is the equivalent of this kind apache logging: :

    LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon :

    LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon

So this adds the Host part to the normal kind of logging ncsa is doing.

Taken that this is a very common way to log virtual hosts I would say
the -v option is not just some hack to suit my own needs, I think it
is usefull for others also.

Without this I am not able to use awstats the way we used it when we
where not using varnish.

Attached you will find the diff against the current trunk.

Rob Halff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: varnishncsa_virtual_host_patch.diff
Type: application/octet-stream
Size: 1119 bytes
Desc: not available
URL: <>

More information about the varnish-dev mailing list