Where the open source database community meets: Use code PERCONA75 and secure your spot for Percona Live.  Register

HAProxy: Give me some logs on CentOS 6.5!

October 3, 2014
Author
Stephane Combaudon
Share this Post:

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!

0 0 votes
Article Rating
Subscribe
Notify of
guest

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

Well done. Worked like a charm.

Gary A Stafford
11 years ago

Perfect! Thanks for easy-to-follow directions.

dashout
dashout
10 years ago

Thanks a lot, sir!

Ivan
Ivan
10 years ago

thanks,works well

Todd Lyons
10 years ago

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

tehmasp
tehmasp
10 years ago

thanks; very clear and concise!

Adel GACEM
Adel GACEM
10 years ago

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

xibu
xibu
10 years ago

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
9 years ago

Very helpful, thank you!

ssbb
ssbb
8 years ago

Works well.

Umapathy Reddy
Umapathy Reddy
8 years ago

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
Niyi
8 years ago
Reply to  Umapathy Reddy

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
8 years ago

work perfectly!
ty

Alvaro Lozano
7 years ago

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

Fernando Chmielewsky
Fernando Chmielewsky
7 years ago

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
6 years ago

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”

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved