How to debug VCL in varnish?

前端 未结 2 1042
暗喜
暗喜 2020-12-28 16:30

How can I print a log in VCL?

Can I print log info on screen?

Can I do like this?

sub vcl_recv {
  ....
  log.info(req.http.host         


        
2条回答
  •  遥遥无期
    2020-12-28 17:10

    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 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

    See also man varnishlog

提交回复
热议问题