HAProxy is frequently used as a load-balancer in front of a Galera cluster. While diagnosing an issue with HAProxy configuration, I realized that logging doesn’t work out of the box on CentOS 6.5. Here is a simple recipe to fix the issue.
If you look at the top of /etc/haproxy/haproxy.cfg, you will see something like:
|
1 |
global<br> log 127.0.0.1 local2<br>[...]<br> |
This means that HAProxy will send its messages to rsyslog on 127.0.0.1. But by default, rsyslog doesn’t listen on any address, hence the issue.
Let’s edit /etc/rsyslog.conf and uncomment these lines:
|
1 |
$ModLoad imudp<br>$UDPServerRun 514<br> |
This will make rsyslog listen on UDP port 514 for all IP addresses. Optionally you can limit to 127.0.0.1 by adding:
|
1 |
$UDPServerAddress 127.0.0.1<br> |
Now create a /etc/rsyslog.d/haproxy.conf file containing:
|
1 |
local2.* /var/log/haproxy.log<br> |
You can of course be more specific and create separate log files according to the level of messages:
|
1 |
local2.=info /var/log/haproxy-info.log<br>local2.notice /var/log/haproxy-allbutinfo.log<br> |
Then restart rsyslog and see that log files are created:
|
1 |
# service rsyslog restart<br>Shutting down system logger: [ OK ]<br>Starting system logger: [ OK ]<br><br># ls -l /var/log | grep haproxy<br>-rw-------. 1 root root 131 3 oct. 10:43 haproxy-allbutinfo.log<br>-rw-------. 1 root root 106 3 oct. 10:42 haproxy-info.log<br> |
Now you can start your debugging session!
Resources
RELATED POSTS