How to configure vcl_log
In order to configure vcl_log, you’ll use custom VCL.
For example, the variable resp.bytes_written
is available in vcl_log
, not vcl_deliver.
So here’s how you would configure that (this assumes that you already have logging set up via the UI):
-
Copy your current log format from
vcl_deliver
and add that to your custom VCL under a new subroutine,vcl_log
. Include any additional variables you would like to the format string (e.g., in this scenario,resp.bytes_written
). -
Add a condition to your log in the UI that will always be false (e.g.
if (!req.url)
), thus prioritizing your logging configuration set invcl_log
overvcl_deliver.
Your file should look something similar to:
sub vcl_log{
log {"syslog <service_id> <logging endpoint name> :: "} req.http.Fastly-Client-IP {" "} {""-""} {" "} {""-""} {" "} now {" "} req.request " " req.url {" "} resp.bytes_written {" "};
}
Note: In custom VCL be sure to include the #FASTLY deliver
macro in your vcl_deliver
handler.
-
The link about custom VCL is broken, use this one instead https://docs.fastly.com/guides/vcl/uploading-custom-vcl
Please sign in to leave a comment.
Comments
2 comments