当我尝试使用 std.syslog 时,Varnish 基本配置文件抛出 "VCL compilation failed"。为什么?
Varnish basic config file throws "VCL compilation failed" when I try to use std.syslog. Why?
我有一个简单的 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');
但其中 none 有效。
如何从我的 VCL 文件进行简单的日志记录?
谢谢。
更新:std.log("hello")
似乎可以编译...但是,我需要记录有关请求对象的信息并且 req
、request
等不存在。
改用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 {
}
我有一个简单的 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');
但其中 none 有效。
如何从我的 VCL 文件进行简单的日志记录?
谢谢。
更新:std.log("hello")
似乎可以编译...但是,我需要记录有关请求对象的信息并且 req
、request
等不存在。
改用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 {
}