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:

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:

This will make rsyslog listen on UDP port 514 for all IP addresses. Optionally you can limit to 127.0.0.1 by adding:

Now create a /etc/rsyslog.d/haproxy.conf file containing:

You can of course be more specific and create separate log files according to the level of messages:

Then restart rsyslog and see that log files are created:

Now you can start your debugging session!

16 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Zo

Well done. Worked like a charm.

Gary A Stafford

Perfect! Thanks for easy-to-follow directions.

dashout

Thanks a lot, sir!

Ivan

thanks,works well

Todd Lyons

This was awesome, thanks for making such a clear and concise post.

tehmasp

thanks; very clear and concise!

Adel GACEM

best that 2 kilos of official blabla
Worked like a charm
@del.

xibu

if i can add something … to prevent the haproxy messages to continue filling-up /var/log/messages, add
‘& ~’ => rsyslog rsyslog >= v.7

# vi /etc/rsyslog.d/haproxy.conf
local0.* /var/log/haproxy.log
& ~
:wq

credit:
http://serverfault.com/questions/214312/how-to-keep-haproxy-log-messages-out-of-var-log-syslog

Anton Kushch

Very helpful, thank you!

ssbb

Works well.

Umapathy Reddy

same logic was implemeted, in linux. unfortunately it didn’t work for me. no issues while restarting both rsyslog and haproxy services but no logs were created

Niyi

Exact same thing happened to me. I followed the instructions to a tee. Still did not work. Did you end up finding a solution?

Mario Chavez

work perfectly!
ty

Alvaro Lozano

Thanks, great post, and it works on CentOS 7 as well.

Fernando Chmielewsky

It didn’t work for me 🙁 the logs are not even created by rsyslog… I’ve been strugling with this issue for a couple of days, googled everything I could, everything leads to the same kind of posts
SO: RHEL 7.5
haproxy version 1.5.18-7.el7

I added the exact config mentioned on this post
any clues?

Matt @ nurango

Thank’s a bunch! For anyone with issues till. Make sure you create the file first and give it any necessary permissions as well. Eg; “touch /var/log/haproxy/haproxy.log”