varnishlog and logging errors

Hugo Cisneiros (Eitch) hugo.cisneiros at
Wed Oct 19 19:25:58 CEST 2011

On Wed, Oct 19, 2011 at 7:25 AM, Audun Ytterdal <audun at> wrote:
> Hi list
> I'm trying to figure out the best way of logging errors in varnish to
> a logfile. The scenario am looking at is when a client get some HTTP
> 5XX message i want to know as much as possible about that error. The
> cause of the error could be many things
> My alternatives are varnishlog and varnishncsa.

I use syslog to do it. When a request goes to vcl_error, I log it,
including the status of the object for example. It's a bit more
difficult to do (since it uses C variables, not VCL language ones),
but works very fine.

For example:

In the beginning of default.vcl:

        #include <syslog.h>

Then on vcl_error:

if (obj.status >= 500) {
                syslog(LOG_INFO, "Error (%s) (%s) (%s)",
VRT_r_req_url(sp), VRT_r_obj_response(sp), VRT_r_req_xid(sp));



More information about the varnish-misc mailing list