如何在 VCL 中打印日志
?
我可以在屏幕上打印日志信息吗?
我可以这样做吗?
sub vcl_recv {
....
log.info(req.http.host); // can i write a log here?
....
}
如何在 VCL 中打印日志
?
我可以在屏幕上打印日志信息吗?
我可以这样做吗?
sub vcl_recv {
....
log.info(req.http.host); // can i write a log here?
....
}
varnishlog -i RxURL
import std;
sub vcl_recv {
...
std.syslog(180, "RECV: " + req.http.host + req.url);
...
}
或者在Varnish 2.x上使用C代码片段 https://www.varnish-cache.org/trac/wiki/VCLExampleSyslog
import std;
https://www.varnish-cache.org/docs/3.0/reference/vmod.html - ghloogh使用vcl配置文件,导入额外包含的“标准库”,其中包括一堆实用函数:
import std;
# To 'varnishlog'
std.log("varnish log info:" + req.host);
# To syslog
std.syslog( LOG_USER|LOG_ALERT, "There is serious trouble");
v6.x - https://varnish-cache.org/docs/6.0/reference/vmod_generated.html#void-log-string-s
v5.x - https://varnish-cache.org/docs/5.0/reference/vmod_std.generated.html?#func-log
v4.x - https://varnish-cache.org/docs/4.0/reference/vmod_std.generated.html?#func-log
v3.x - https://varnish-cache.org/docs/3.0/reference/vmod_std.html#log
请参见man varnishlog
varnishd -Cf file_name
。 - Tamil