如何logging来自HAProxy的请求?

我设置HAProxy作为负载平衡器,我可以得到它的工作(这是转发请求到后端)。 但是,我不能让它将每个请求logging到文件。 我可以看到像这样的系统types消息:

Mar 3 19:36:33 rg-staging-balancer haproxy-systemd-wrapper[29244]: haproxy-systemd-wrapper: SIGTERM -> 8750. Mar 3 19:36:33 rg-staging-balancer haproxy-systemd-wrapper[29244]: haproxy-systemd-wrapper: exit, haproxy RC=0 Mar 3 19:36:33 rg-staging-balancer haproxy-systemd-wrapper[18109]: haproxy-systemd-wrapper: executing /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds 

不是个别的要求。 我正在运行Ubuntu 16.04,HAProxy 1.7.2-1ppa1〜xenial这个configuration:

 global log 127.0.0.1 local1 notice tune.ssl.default-dh-param 2048 defaults timeout client 10s timeout server 10s timeout connect 10s frontend http reqadd X-Forwarded-Proto:\ https maxconn 2000 bind :443 ssl crt /etc/ssl/haproxy.pem default_backend rails_servers backend rails_servers mode http option httpchk option forwardfor server rg_staging 192.168.203.139:80 

任何想法如何获得每个请求logging?

您是否尝试过在rsyslog上启用UDP日志logging(默认禁用),并为LOCAL1(这是您正在使用的工具)添加设施?

确保这些行在/etc/rsyslog.conf中没有被注释掉

$ModLoad imudp

$UDPServerRun 514

添加此行以将HAProxylogging到上述configuration文件中:

 local1.* /var/log/haproxy.log 

你必须放

 mode http option httplog 

在你的前端为了loggingHTTP请求。