varnishncsa -F flag custom log format

Rowan @ Jetboy rowan at jetboy.co.uk
Sat May 26 23:24:41 CEST 2012


Running Varnish 3.02 rev. cbf1284 on Ubuntu Server 12.04 LTS x64:

 

I can get varnishncsa writing to logs successfully with:

 

VARNISHNCSA_ENABLED=1

DAEMON_OPTS="-a \

             -c \

             -D \

             -P ${PIDFILE} \

             -w /var/log/varnish/hollywood.varnishncsa.log"

 

in /etc/default/varnishncsa

 

but I'm really struggling with the -F flag for custom log formats. I'm
trying to achieve an Apache combined log format prefixed by the virtual
host, which'd look something like this:

 

%{Host}i %h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"

 

but all I'm managing to do is capture the %{Host}i bit in the logfile.

 

There's an old thread on here about issues with spaces and escaping quotes,
but the responses are all about setting the format on the command line,
which I'm really trying to avoid. I've got to:

 

VARNISHNCSA_ENABLED=1

FORMAT="%{Host}i %h %l %u %t \"%r\" %s %b \"%{Referer}i\"
\"%{User-agent}i\""

DAEMON_OPTS="-a \

             -c \

             -D \

             -F ${FORMAT} \

             -P ${PIDFILE} \

             -w /var/log/varnish/hollywood.varnishncsa.log"

 

I've tried various permutations of single and double quotes, and the format
both in and out of a variable. No luck so far. Can anyone help me out?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120526/cac93dbf/attachment.html>


More information about the varnish-misc mailing list