Haproxy The log is not logged by default, and the configuration file for the system log is required, in addition to specifying the output of the log in the global segment in haproxy.conf. Take centos6.4 as an example, Haproxy uses the system's own RPM newspaper version 1.4
1, vim/etc/haproxy/haproxy.conf
Global
Log 127.0.0.1 Local3 #local3是设备, corresponding to the configuration in/etc/rsyslog.conf, the default recycle info logging level
Maxconn 1024
User Haproxy
Group Haproxy
Daemon
Pidfile/var/run/haproxy.pid
Defaults
Mode http
Log Global
Option Httplog
Option Dontlognull
Option Http-server-close
Option Forwardfor except 127.0.0.0/8
Retries 2
Option Redispatch
Maxconn 1024
2. Edit System Log Configuration
Vim/etc/rsyslog.conf
By default, the following settings will read the configuration file in the/etc/rsyslog.d/*.conf directory
$IncludeConfig/etc/rsyslog.d/*.conf
Create a separate configuration file for Haproxy
Vim/etc/rsyslog.d/haproxy.conf
$ModLoad IMUDP
$UDPServerRun 514
local3.*/var/log/haproxy.log
The message file is also written to the log in Aproxy.log
&~
3, configure the Rsyslog of the main configuration file, open the remote log
Vim/etc/sysconfig/rsyslog
Syslogd_options= "-C 2-r-M 0″
#-c 2 uses compatibility mode, the default is-C 5
#-r Open Remote Log
#-m 0 marks the timestamp. The unit is minutes, 0 o'clock, which means that the feature is disabled
Restart Haproxy and Rsyslog services after configuration is complete
/etc/init.d/rsyslog restart
/etc/init.d/haproxy restart
4, on the Red Hat 5 configuration system log and Red Hat 6 different, Red Hat 5/etc/rsyslog.conf does not contain/etc/rsyslog.d/*.conf, configured as follows
#加入haproxy. None indicates that the Haproxy log is not written to the message
*.info;mail.none;authpriv.none;cron.none;haproxynone/var/log/messages
local3.*/var/log/haproxy.log