Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Logging 将HAProxy配置为记录请求正文_Logging_Haproxy_Document Body - Fatal编程技术网

Logging 将HAProxy配置为记录请求正文

Logging 将HAProxy配置为记录请求正文,logging,haproxy,document-body,Logging,Haproxy,Document Body,我知道从1.6.0版开始,可以使用HAProxy记录POST请求的主体。下面指出,我们需要以某种方式使用req.body,并以日志格式记录capture.req.hdr 在上述链接中询问的人的配置中有以下前端: frontend www-http bind 0.0.0.0:9000 option http-buffer-request declare capture request len 400000 http-request capture req.body

我知道从1.6.0版开始,可以使用HAProxy记录POST请求的主体。下面指出,我们需要以某种方式使用req.body,并以日志格式记录capture.req.hdr

在上述链接中询问的人的配置中有以下前端:

frontend www-http
    bind 0.0.0.0:9000

    option http-buffer-request
    declare capture request len 400000
    http-request capture req.body id 0
    log-format {"%[capture.req.hdr(0)]"}
但这大概是错误的,因此他们提出了问题


执行此操作的确切语法是什么?

这对我来说适用于自定义日志格式:

global
        log     127.0.0.1 local0
        debug
        maxconn 2048
        ulimit-n 8012
#        ...

defaults
    mode http
    option httplog
    log-format frontend:%f/%H/%fi:%fp\ client:%ci:%cp\ GMT:%T\ body:%[capture.req.hdr(0)]\ request:%r
    option dontlognull
#   ...

frontend www-http
   log global
   option http-buffer-request
# id=0 to store body for logging
   declare capture request len 40000
   bind 7.7.7.7:8007 
   http-request capture req.body id 0

   default_backend www-backend

backend www-backend
    mode http
    option forwardfor
#   ...