How to debug VCL in varnish?

回眸只為那壹抹淺笑 提交于 2019-11-30 03:14:50
ghloogh

You can see URL with requested URLs varnishlog utility (it able to write log files)

varnishlog -i RxURL

Or output some info to syslog with vmod std and syslog function for Varnish 3.x https://www.varnish-cache.org/docs/trunk/reference/vmod_std.html#syslog Varnish 5.1 https://varnish-cache.org/docs/5.1/reference/vmod_std.generated.html#func-syslog

Example:

import std;

sub vcl_recv {
  ...
  std.syslog(180, "RECV: " + req.http.host + req.url);
  ...
}

Or with C-snippet on Varnish 2.x https://www.varnish-cache.org/trac/wiki/VCLExampleSyslog

Using a vcl config file, import the additional included "standard library", which includes a bunch of utility functions:

import std;

# To 'varnishlog'
std.log("varnish log info:" + req.host);

# To syslog
std.syslog( LOG_USER|LOG_ALERT, "There is serious troble");

v5.x - https://www.varnish-cache.org/docs/5.0/reference/vmod_std.generated.html?#func-log

v4.x - https://www.varnish-cache.org/docs/4.0/reference/vmod_std.generated.html?#func-log

v3.x - (deprecated) https://www.varnish-cache.org/docs/3.0/reference/vmod_std.html#log

See also man varnishlog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!