6

I tried everything:

service varnishlog start - logs everything

varnishlog -D -c -m TxStatus:503 > /var/log/varnish/varnish.log - doesn't seem to be doing anything

varnishlog -c -m TxStatus:503 > /var/log/varnish/varnish.log - only logs until I close my SSH connection

I'm out of options, any help?

Note: varnishncsa is not an option, since it doesn't tell me which error causes the 503. I'm running Varnish 3.x (latest) and CentOS 5.8 with Apache 2 as backend.

2 Answers 2

3

If I understand correctly varnishlog -c -m TxStatus:503 > /var/log/varnish/varnish.log does meet your needs but has the downside to stop once you close ssh.

If you need to temporary log 503 error, like for a few months, time to debug a problem, then you can look at nohup or screen.

If you need to permanently log 503 error, have a look at varnishlog init script (/etc/init.d/varnishlog ).

1
  • Editing /etc/init.d/varnishlog had no effect (still logged all hits). Tried nohup, logged in again and it's still in the process list, so I'm guessing it worked. Thanks! Aug 3, 2012 at 11:01
12

For those who land here in frustration looking for solution to the same problem in Varnish 4, see below:

varnishlog -a -w /var/log/varnish/varnish50x.log -q "RespStatus >= 500 or BerespStatus >= 500"

Varnish 4 did away with the -m option in varnishlog and instead came up with a new filter query language called VSL which is available in the new option -q. In the above command, -a provides appendonly option instead of overwriting the file, -w allows to write output to a file and -q is for the VSL query. Above command will log entries where varnish response or backend response status is >=500 (including the dreaded 503 error).

2
  • Thank you, this command launched in a tmux shell worked like a charm! Oct 7, 2015 at 11:09
  • 2
    If you use latest Varnish 4.1, remember to add "-A" to the parameters (so the list becomes -a -A -w ... to have an ASCII log (otherwise Varnish writes a binary log) Oct 19, 2015 at 10:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .