Logging to syslog via Embedded C and http-range support

Wido den Hollander wido at widodh.nl
Wed Nov 3 14:51:14 CET 2010

Hi all,

In our current setup (without Varnish) we have a cluster of Apache
webservers which all log to syslog.

Via a remote-syslog machine we collect all the logs and parse them and
do with them what we want.

We use a specific logformat, so using varnishncsa is not possible (yet).

Right now I've written the following code:

sub vcl_deliver {
    time_t rawtime;
    struct tm * timeinfo;
    char timebuffer[80];

    timeinfo = localtime(&rawtime);
    strftime(timebuffer, 80, "[%d/%b/%Y:%T %z]", timeinfo);

    char *referer = VRT_GetHdr(sp, HDR_REQ, "\010Referer:");
    if (referer == NULL) {
        referer = "-";

    char *useragent = VRT_GetHdr(sp, HDR_REQ, "\013User-Agent:");
    if (useragent == NULL) {
        useragent = "-";

        "%s %s %s - - \"%s %s %s\" %d %s \"%s\" \"%s\"",
        VRT_GetHdr(sp, HDR_REQ, "\005Host:"),
        VRT_IP_string(sp, VRT_r_client_ip(sp)),
        VRT_GetHdr(sp, HDR_RESP, "\017Content-Length:"),

This works fine, I get the logs in the format I want it to be, but when
enabling http_range_support I get strange behaviour.

$ curl -i -r 0-500 <url>

When doing that, I get a 206 response from Varnish with a Content-Length
of 501 bytes, but my logfile shows a obj_status of 200 and a
Content-Length of almost 10kb (the actual size of the object).

It seems to me that the actual headers to the client are somewhere
overwritten when using http_range_support.

Is this because of the experimental http_range_support? Or is it
possible to collect the correct data somewhere so I can log it?

Thank you,


More information about the varnish-misc mailing list