Haproxy不logging捕获的具有自定义日志格式的请求标头

早些时候,我没有指定一个自定义的日志格式,捕获的请求标题打印得很好。 我想loggingunique-id-header ,但找不到任何方法。 所以我复制粘贴在http://haproxy.1wt.eu/download/1.5/doc/configuration.txt上提到的日志格式,唯一的ID开始获取logging。

不幸的是,现在捕获的请求标头没有被logging。 %hrl and %hsl作为空string出现。

很奇怪。 这是我的configuration,plzz帮助:(

 listen server bind *:80 mode http option httplog option http-server-close no option logasap # disable early logging of HTTP requests so that total transfer time is logged option forwardfor capture request header X-Forwarded-For len 500 capture request header Host len 500 capture request header X-Request-UID len 500 rspadd X-Haproxy-Backend:\ server # Generate the X-Haproxy-Unique-ID and log it to make it easy to track requests log-format %Ci:%Cp\ [id=%ID]\ [%t]\ %f\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %st\ %B\ %cc\ %cs\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ {%hrl}\ {%hsl}\ %{+Q}r unique-id-format %{+X}o\ %Ci:%Cp_%Fi:%Fp_%Ts_%rt:%pid unique-id-header X-Haproxy-Unique-ID 

这里是我看到的日志:

 Sep 13 17:28:57 localhost haproxy[11979]: 10.161.27.218:41592 [id=0AA11BDA:A278_0AA15B71:0050_505217C5_0014:2ECB] [13/Sep/2012:17:28:37.567] server www-example-com-healthz/- 19998/0/2/1/+20001 200 +326 - - ---- 10/10/1/1/0 0/0 {} {} "GET /testing/healthz?merchant=www.example.com&source=elb HTTP/1.1" 

请注意%hrl and %hsl是空string:(我如何捕获请求头?

默认情况下,这些字段将在日志中显示为空。 为了logging标题和cookie,必须在前端设置捕获参数。

这里是我们如何捕获HTTP请求中的客户端发送的头。

 capture request header Referrer len 64 capture request header Content-Length len 10 capture request header User-Agent len 64 

更新configuration,因为一些值已被弃用

  capture request header X-Request-UID len 500 #Generate the X-Haproxy-Unique-ID and log it to make it easy to track requests log-format %ci:%cp\ [id=%ID]\ [%t]\ %f\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\ %CC\ %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ {%hrl}\ {%hsl}\ %{+Q}r unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid unique-id-header X-Haproxy-Unique-ID