HAProxy日志开启

安装完haproxy后默认是没有启用日志的,如果需要日志配置,那么需要结合rsyslog

修改haproxy配置

在全局配置段中配置,定义日志记录级别。

global
    log 127.0.0.1 local3  info

修改rsyslog配置

#日志传输基于udp
[root@LB ~]# sed -n '21,22p' /etc/rsyslog.conf
$ModLoad imudp
$UDPServerRun 514

#文件末尾添加
local3.*			/var/log/haproxy.log
[root@LB ~]# systemctl restart haproxy rsyslog

没什么问题后访问一下就会在/var/log/haproxy.log中看到日志

[root@LB ~]# tail -f /var/log/haproxy.log
May 10 07:00:15 localhost haproxy[1760]: Connect from 192.168.248.1:62485 to 192.168.248.200:443 (https/TCP)
May 10 07:00:15 localhost haproxy[1760]: Connect from 192.168.248.1:62486 to 192.168.248.200:443 (https/TCP)
May 10 07:00:20 localhost haproxy[1760]: Connect from 192.168.248.1:62490 to 192.168.248.200:443 (https/TCP)
May 10 07:00:20 localhost haproxy[1760]: Connect from 192.168.248.1:62491 to 192.168.248.200:443 (https/TCP)
May 10 07:00:24 localhost haproxy[1760]: Connect from 192.168.248.1:62495 to 192.168.248.200:443 (https/TCP)
原文地址:https://www.cnblogs.com/diqiyao/p/14749274.html