Enabling HAProxy Logging

A quick guide on enabling basic logging on a haproxy server running CentOS 6.5

The reason behind HAProxy not logging by default is that it sends to rsyslog on UDP port 514 which rsyslog does not listen on by default.

All that is required to enable logging on Haproxy will be to create a config file in rsyslog as below

nano /etc/rsyslog.d/haproxy.conf

$ModLoad imudp
$UDPServerRun 514
$template Haproxy,”%msg%\n”
local0.* -/var/log/haproxy.log;Haproxy
### keep logs in localhost ##
local0.* ~

This will tell rsyslog to listen on UDP port 514 and log any haproxy logs to /var/log/haproxy.log.

You should now restart rsyslog and haproxy to update these changes.

service rsyslog restart
service haproxy restart

Any comments or questions? Get in touch here or Email me at [email protected]