Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 270597 - www-servers/varnish doesn't set up any logging
Summary: www-servers/varnish doesn't set up any logging
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Thilo Bangert (RETIRED) (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-20 16:49 UTC by Joshua Bronson
Modified: 2009-07-12 12:04 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Bronson 2009-05-20 16:49:15 UTC
The way varnish works is it doesn't log to a file or stdout but rather to shared memory, and you can use the varnishlog utility to read it through stdout. Varnish also provides the varnishncsa utility which reads this output and rewrites it in the familiar apache/ncsa access log style. Unfortunately when you emerge varnish it doesn't set up any logging, so here's what I did to get it working:

* created the directory /var/log/varnish

* added the following line to /etc/conf.d/varnishd:
LOGFILE="/var/log/varnish/access.log"


* added the following lines to /etc/init.d/varnishd:
+++ /etc/init.d/varnishd        2009-05-20 12:17:44.000000000 -0400
@@ -12,11 +12,13 @@
        #allow varnishd to lock logfile to memory
        ulimit -l 82000
        start-stop-daemon --quiet --start --pidfile /var/run/varnishd.pid --exec /usr/sbin/varnishd -- -P /var/run/varnishd.pid ${VARNISHD_OPTS} &> /dev/null
+       start-stop-daemon --quiet --start --pidfile /var/run/varnishncsa.pid --exec /usr/bin/varnishncsa -- -D -P /var/run/varnishncsa.pid -a -w ${LOGFILE}
        eend $?
 }
 
 stop() {
        ebegin "Stopping varnish"
        start-stop-daemon --quiet --stop --pidfile /var/run/varnishd.pid
+       start-stop-daemon --quiet --stop --pidfile /var/run/varnishncsa.pid
        eend $?
 }


* created the file /etc/logrotate.d/varnish with the following content:
/var/log/varnish/*.log {
  weekly
  rotate 10
  copytruncate
  delaycompress
  compress
  notifempty
  missingok
}


So varnishncsa will automatically start/stop along with varnishd via the varnishd initscript, and the last 10 logfiles can be found in /var/log/varnish.

Just wanted to share in case this would be useful for other people. I believe the Debian varnish package sets up logging automatically, but I'm not sure. If so, it could also be useful for comparison.
Comment 1 Tim Taubert 2009-06-30 22:09:05 UTC
works like a charm. this should be added to the default ebuild. an important parameter is "-c" which only logs client communication. this is what most people probably want in order to work with e.g. awstats.

thanks.
Comment 2 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2009-07-12 12:04:44 UTC
this is implemented in 2.0.4-r1.
thanks for the suggestion and implementation.

kind regards
Thilo