How to configure the log for HaProxy

To enable HaProxy logging edit /etc/sysconfig/rsyslog - bring the only line there to the following form:

SYSLOGD_OPTIONS="-c 2 -r"

In fact you need to add the -r flag to the options of the rsyslog daemon to let it accept events on an ip socket.

Next edit the /etc/rsyslog.conf file:

  1. First uncomment the following lines:
# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514

and

# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514
  1. Now what is left is to create the corresponding logfacility. If the global section of your haproxy config file says the following:
log         127.0.0.1 local2

then throw this line into rsyslog.conf:

local2.*                                                /var/log/haproxy.log

For the changes to take effect you need to restart the rsyslog daemon:

/etc/init.d/rsyslog restart

Share Button