varnish - 如何在varnish中调试VCL?

标签 varnish varnish-vcl

如何在 VCL 中打印日志

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

我可以这样做吗?

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

最佳答案

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

varnishlog -i RxURL

或者使用 vmod std 和 syslog 函数将一些信息输出到 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#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

关于varnish - 如何在varnish中调试VCL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12576248/

相关文章:

REST API 缓存,我应该使用反向代理还是 memcache(d)?

tomcat - Nginx + Varnish 4 对所有请求返回 200 空响应

chef-infra - Varnish HAproxy Recipe

caching - Varnish:POST 数据后清除缓存

caching - varnish 可以用作代理来缓存和服务第三方资源吗?

ruby-on-rails - Heroku & Rails - Varnish 只是偶尔缓存

caching - 如何清除节点队列的 Varnish 缓存?

php - 无法删除标题 "vary: user agent"

正则表达式匹配任何不是子模式的东西

Varnish - 为什么有两个过程