清漆基本配置文件在我尝试使用 std.syslog 时抛出"VCL compilation failed"。为什么?



我有一个简单的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")似乎编译...但是,我需要记录有关请求对象的信息,reqrequest等不存在。

改用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 {
}

相关内容

最新更新