rotating the varnishncsa log file
nkinkade at creativecommons.org
Fri Sep 5 19:39:23 CEST 2008
2008/9/4 Chris Johnson <cjohnson at socialvibe.com>:
> Does anyone successfully have logrotate working with varnishncsa?
Below is the solution I came up with. The lastaction part may not be
necessary for anyone else, but on occasion it seemed to be necessary
for us, and rather than spending much time looking into the underlying
cause I'm okay with this solution.
/usr/sbin/invoke-rc.d varnishlog reload > /dev/null
# varnishlog or varnishncsa(??) seems to produce a lot of entries
that are null,
# the grep -v in the middle just attempts to eliminate them
/usr/bin/ionice -c3 /usr/bin/varnishncsa -r
$VDIR/varnish.log-$DATE | grep -v '^- - -' | gzip >
$VDIR/varnish.log-$DATE.gz && rm $VDIR/varnish.log-
# Sometimes, for reasons that I can't explain, varnishlog stops
# rotation. The new log just sits there at 0 bytes and it takes a reload to
# make it start logging again. It could be some complex timing issue, but
# hopefully just adding one last restart of varnishlog will be enough.
/usr/sbin/invoke-rc.d varnishlog force-reload > /dev/null
More information about the varnish-misc