我有一个简单的VCL文件如下:
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 {
}
当我尝试在Mac上使用此配置启动varnishd
时,出现以下错误:
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
我尝试过这一行的不同变体:
std.log("req.host: "+req.host);
如:
std.log(req.host: '+req.host);
std.log("req.host: ",req.host);
std.log('req.host: ',req.host);
std.log('hello');
但它们都不起作用。
如何从我的VCL文件中进行简单的日志记录?
感谢。
更新:std.log("hello")
似乎在编译......但是,我需要记录有关请求对象的信息,并且req
,request
等不存在。
答案 0 :(得分:1)
改为使用req.http.host
:
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 {
}