I have a simple VCL file as follows:
vcl 4.0;
import std;
backend default {
.host = "127.0.0.1";
.port = "3333";
}
sub vcl_recv {
std.log("req.host: "+req.host);
}
sub vcl_backend_response {
}
sub vcl_deliver {
}
When I try to start varnishd
with this config on my Mac, I get the following error:
Error:
Message from VCC-compiler:
Symbol not found: 'req.host' (expected type STRING):
('/Users/jononomo/dev/my_project/deploy/testing.vcl' Line 30 Pos 26)
std.log("req.host: "+req.host);
-------------------------########--
('/Users/jononomo/dev/my_project/deploy/testing.vcl' Line 30 Pos 5) -- ('/Users/jononomo/dev/my_project/deploy/testing.vcl' Line 30 Pos 25)
std.log("req.host: "+req.host);
----#####################----------
Running VCC-compiler failed, exited with 2
VCL compilation failed
I have tried different variations of this line:
std.log("req.host: "+req.host);
such as:
std.log(req.host: '+req.host);
std.log("req.host: ",req.host);
std.log('req.host: ',req.host);
std.log('hello');
but none of them work.
How can I do simple logging from my VCL file?
Thanks.
UPDATE: std.log("hello")
seems to compile... however, I need to log information about the request object and req
, request
, etc do not exist.
Use req.http.host
instead:
vcl 4.0;
import std;
backend default {
.host = "127.0.0.1";
.port = "3333";
}
sub vcl_recv {
std.log("req.host: " + req.http.host);
}
sub vcl_backend_response {
}
sub vcl_deliver {
}