是否可以在VCL中使用std.log输出ReqEnd?我想在varnishncsa日志记录中使用ReqEnd。
最佳答案
我不知道你是否可以在 varnishnsca 中记录 ReqEnd 但你可以记录请求开始时间和 xid。
vcl 示例:
........
C{
#include <syslog.h>
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
}C
sub vcl_recv {
C{
struct timeval detail_time;
gettimeofday(&detail_time,NULL);
char start[20];
sprintf(start, "%lu%06lu", detail_time.tv_sec, detail_time.tv_usec);
VRT_SetHdr(sp, HDR_REQ, "\020X-Request-Start:", start, vrt_magic_string_end);
}C
........
sub vcl_deliver {
set resp.http.X-ID = req.xid;
}
.......
你可以看到它:
varnishncsa -F "%{X-Request-Start}o %{X-ID}o"
关于使用标准输出 Varnish 输出ReqEnd,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13527886/