Tips for debugging VCL


This stack overflow post has a great example on debugging VCL through varnishlog output. Is there a way to do something similar with Fastly’s logging tools, or through headers?


While we don’t support std.syslog directly, we have a streaming log service available that you can use for this sort of thing. See for how to set up a logging endpoint.

Once you have setup a logging endpoint as described in that document, you should see something like this in your generated VCL:

  log {"syslog bm90IGEgcmVhbCBzaWQK :: "} req.http.Fastly-Client-IP {" "} {""-""} {" "} {""-""} {" "} now {" "} req.request " " req.url {" "} resp.status;

The syslog keyword is always there, even if you use other logging services, like an S3 bucket. The two strings after that are the service ID and the endpoint name. These two are used by our logging service to determine where everything after the :: is sent.

So if you want to send some debugging info through our logging service all you have to do is copy the first part of that line, and paste it where you want in your VCL, followed by the info you want.

For example:

sub vcl_recv {
  log {"syslog bm90IGEgcmVhbCBzaWQK :: RECV: "} req.url;
  if (req.http.Cookie) {
    log {"syslog bm90IGEgcmVhbCBzaWQK :: stripping Cookie: "} req.http.Cookie;
    unset req.http.Cookie;
#FASTLY recv
    if (req.request != "HEAD" && req.request != "GET" && req.request != "FASTLYPURGE") {



The curly braces around the strings mean that they’re “long strings”. This means that double quotes and newlines can be used inside them, as well as other subtle differences. For more info on that see