Justin Hourigan
Justin Hourigan

Reputation: 783

Varnish outputting ReqEnd using standard out

Is it possible to output ReqEnd using std.log in VCL? I would like to use ReqEnd in varnishncsa logging.

Upvotes: 1

Views: 402

Answers (1)

mrege
mrege

Reputation: 1861

I don't know if you can log ReqEnd in varnishnsca but you can log the request start time and xid.

vcl example:

........
C{
    #include <syslog.h>
    #include <sys/time.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
}C

sub vcl_recv {

    C{
        struct timeval detail_time;
        gettimeofday(&detail_time,NULL);
        char start[20];
        sprintf(start, "%lu%06lu", detail_time.tv_sec, detail_time.tv_usec);
        VRT_SetHdr(sp, HDR_REQ, "\020X-Request-Start:", start, vrt_magic_string_end);
    }C

........

sub vcl_deliver {
    set resp.http.X-ID = req.xid;
}
.......

and you can see it: varnishncsa -F "%{X-Request-Start}o %{X-ID}o"

Upvotes: 1

Related Questions