Monday, 25 July 2016

Setting up HAProxy and RSyslog with CentOS 7

HAProxy provides built-in syslog support and can be enabled pretty easily - in your configuration within the 'defaults' stanza add something like the following:

log haproxy notice

and then in your rsyslog.conf we add / uncomment:

$ModLoad imudp
$UDPServerRun 514

We will also want to add the following to ensure that haproxy logs are stored elsewhere -

sudo vi /etc/rsyslog.conf

and insert the following at the top of the '#### RULES ####' section:

if $programname startswith 'haproxy' then /var/log/haproxy.log

Reload rsyslog and haproxy:

sudo service rsyslog reload
sudo service haproxy reload

and then generate some traffic on the proxy and then review the logs:

tail -f /var/log/haproxy.log


Post a Comment