the configuration file involved is as follows 1) /etc/haproxy/haproxy.conf //This is the main configuration file for the Haproxy program, The specific path can be arbitrarily specified, mainly the following sentence log   LOCALHOST   LOCAL0  2) /etc/rsyslog.conf //This configuration file does not move, the default will have the following settings, will read the /etc/rsyslog.d/*.conf directory Configuration files under // $IncludeConfig /etc/rsyslog.d/*.conf 3) /etc/rsyslog.d/haproxy.conf // This file needs to be created manually, as follows: cat /etc/rsyslog.d/haproxy.conf $ModLoad imudp $UDPServerRun 514 $template haproxy, "%rawmsg% \n" local0.=info -/var/log/haproxy.log; haproxy local0.notice -/Var/log/haproxy-status.log; HAPROXY ### KEEP LOGS IN LOCALHOST ## LOCAL0.* ~   4) /etc/sysconfig/rsyslog content as follows  # OPTIONS FOR RSYSLOGD # SYSLOGD options are deprecated since rsyslog v3. # if you want to use them, switch to compatibility mode 2 by "-c 2"  # SEE RSYSLOGD (8) for more details syslogd_options= "-c 2 -r -m 0 " notes: #-c 2 use compatibility mode, default is -c 5 #-r turn on remote log #-m 0 mark the timestamp. The unit is the minute, which is 0 o'clock, which means disable the function Well, the log configuration is mainly related to these files. Also, restart the Rsyslog and Haproxy services to centos 6: /etc/init.d/rsyslog Restart centos 7: systemctl restart rsyslog killlall -9 haproxy && haproxy -f /etc/haproxy/haproxy.conf Finally, the most important point, be sure to open the iptables udp 514 port iptables -I INPUT -m udp -p udp --dport 514 -j ACCEPT Otherwise, a bunch of errors may be reported, such as the following: sendto logger #0 failed: operation not permitted (errno=1)
Configuration of Haproxy logs under CentOS