Relate to configuration file as follows
1)/etc/HAProxy/HAProxy.conf//this is the main configuration file of HAProxy process, specific path can be specified, mainly the following sentence
log localhost local0
2)/etc/rsyslog.conf//this config file not to move, can have the following settings by default, it reads the configuration files in a/etc/rsyslog.d/*.conf directory//
$IncludeConfig /etc/rsyslog.d/*.conf
3)/etc/rsyslog.d/HAProxy.conf//we need to manually create this file, 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 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, the default is-c 5
#-R open the remote log
Mark #-m 0 timestamp. Unit is minutes to 0 o’clock, disables this feature
Well, logging configuration is primarily related to these files.
In addition, HAProxy and then restart the rsyslog service can
centos 6: /etc/init.d/rsyslog restart
centos 7: systemctl restart rsyslog
killlall -9 haproxy && haproxy -f /etc/haproxy/haproxy.conf
Finally, and most important, be sure to open UDP port 514 iptables
iptables -I INPUT -m udp -p udp –dport 514 -j ACCEPT
Or they may report an error, look similar to the following:
sendto logger #0 failed: operation not permitted (errno=1)
Leave a Reply