How to pipe varnishncsa entries?

Paul A. Procacci pprocacci at
Wed Nov 14 15:58:59 CET 2012

On Wed, Nov 14, 2012 at 01:16:41PM +0000, Rowan @ Jetboy wrote:
> ?Ubuntu 12 x64 Server, Varnish 3
> I have varnishncsa happily logging away to itself with the following in
> /etc/default/varnishncsa
>              -c \
>              -D \
>              -F '%{Host}i %{X-Forwarded-For}i %h %l %u %t \"%r\" %s %b
> \"%{Referer}i\" \"%{User-agent}i\"' \
>              -m 'TxHeader:Server: Varnish/3' \
>              -P ${PIDFILE} \
>              -w /var/log/varnish/varnishncsa.log"
> and by changing:
>     if start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
>         --chuid $USER --exec ${DAEMON} -- ${DAEMON_OPTS} \
>         > ${output} 2>&1; then
> to:
>     if bash -c "start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
>         --chuid $USER --exec ${DAEMON} -- ${DAEMON_OPTS} \
>         > ${output} 2>&1"; then
> in /etc/init.d/varnishncsa to allow the sending of parameters with
> whitespace in from DAEMON_OPTS.
> In *addition* to logging locally, I'd like to pipe the same custom format
> log entries to syslog for remote centralised logging, using this pipe:
> |/usr/bin/logger -t varnishncsa.log -p
> Is this possible? If so, how? Ideally I'd like the command within
> DAEMON_OPTS, but my efforts so far haven't resulted in any output to syslog.
> I'm already successfully using a version of the same pipe to put Apache logs
> to syslog.

I'm not familiar with Ubuntu as I use FreeBSD myself, nor bash, as I primarily
use csh, but after reading the start-stop-daemon manpage, there doesn't seem
to be any reason why you couldn't tee(1) stdout.  I imagine something like
the following would work but without having an actual Ubuntu machine to test
on I'm not 100% sure.

if start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
   --chuid $USER --exec ${DAEMON} -- ${DAEMON_OPTS} 2>&1 \
   | tee -a ${output} \
   | /usr/bin/logger -t varnishncsa.log -p



This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you.

More information about the varnish-misc mailing list