What is HAProxy?
HAProxy is an open-source, high availability load balancer that quietly sits in front of any TCP/HTTP service. It's well-known for its efficiency and reliability, and often used to manage the traffic of high-volume and distributed systems.
If you're using HAProxy, you may have come across a situation where you're looking through application logs only to realize that you can't find the information you're looking for. For example, maybe you're looking in apache logs trying to isolate the IP of a web crawler and instead find the IP of your HAProxy instance. Logically, you log in to the machine running HAProxy for further analysis where you hit a roadblock.
Where are HAProxy logs stored?
The default configuration in /etc/haproxy/haproxy.cfg defines the global log parameter, but a search for HAProxy logs will come up empty. That is because rsyslog only uses the imjournal and imusock modules for message reception out of the box.
global log 127.0.0.1 local2 # Additional parameters...
In order to enable logging from HAProxy, you need to configure rsyslog to use the imupd module as well. As root, find and uncomment the following lines in your configuration file:
module(load="imudp") input(type="imudp" port="514")
Now create a configuration file that tells rsyslog where to log HAProxy messages.
sudo echo "local2.* /var/log/haproxy.log" > /etc/rsyslog.d/haproxy.conf
and restart the rsyslog service.
sudo systemctl restart rsyslog
You should now see /var/log/haproxy.log and can get back to debugging. Additional configuration details for logging can be found here: