New in Varnish 3.0.3rc1 is that you can put arbitrary log lines from VCL into the varnishncsa output. This can be used for funky stuff like logging the session cookie along with the request.
Let’s say you have the following VCL and have a session id as the single site cookie:
import std;
sub vcl_deliver {
std.log(“sessionid:” + regsub(req.http.cookie, “.*=”, “”);
}
Run varnishncsa as follows:
# varnishncsa -F ‘%h %l %u %t “%r” %s %b “%{Referer}i” “%{User-agent}i %{VCL_Log:sessionid}x’
And now your access logs contains the session id/cookie string. Great stuff huh?