Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug VCL in varnish?

Tags:

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); // can i write a log here?   .... } 
like image 349
lichengwu Avatar asked Sep 25 '12 04:09

lichengwu


1 Answers

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

like image 139
ghloogh Avatar answered Oct 14 '22 06:10

ghloogh