如何在清漆中调试 VCL? [英] How to debug VCL in varnish?

查看:17
本文介绍了如何在清漆中调试 VCL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 VCL 中打印日志?

我可以在屏幕上打印日志信息吗?

Can I print log info on screen?

我可以这样做吗?

sub vcl_recv {
  ....
  log.info(req.http.host); // can i write a log here?
  ....
}

推荐答案

您可以看到带有请求 URL 的 URL varnishlog 实用程序(它能够写入日志文件)

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

varnishlog -i RxURL

或者使用 vmod std 和 syslog 函数为 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#功能系统日志

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

示例:

import std;

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

或者在 Varnish 2.x 上使用 C-snippet https://www.varnish-cache.org/trac/wiki/VCLExampleSyslog

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

这篇关于如何在清漆中调试 VCL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆