HAProxy: Give me some logs on CentOS 6.5!

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 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 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!

Share this post

Comments (16)

  • Zo

    Well done. Worked like a charm.

    November 14, 2014 at 11:44 am
  • Gary A Stafford

    Perfect! Thanks for easy-to-follow directions.

    January 25, 2015 at 10:42 pm
  • dashout

    Thanks a lot, sir!

    October 1, 2015 at 2:39 am
  • Ivan

    thanks,works well

    November 10, 2015 at 11:06 pm
  • Todd Lyons

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

    November 24, 2015 at 7:57 pm
  • tehmasp

    thanks; very clear and concise!

    December 4, 2015 at 5:17 pm
  • Adel GACEM

    best that 2 kilos of official blabla
    Worked like a charm

    January 19, 2016 at 8:59 am
  • 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
    & ~


    March 7, 2016 at 4:53 am
  • Anton Kushch

    Very helpful, thank you!

    March 24, 2017 at 6:21 am
  • ssbb

    Works well.

    May 19, 2017 at 8:35 am
  • 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

    June 20, 2017 at 2:20 am
    • 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?

      November 1, 2017 at 12:56 pm
  • Mario Chavez

    work perfectly!

    December 26, 2017 at 9:24 am
  • Alvaro Lozano

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

    October 16, 2018 at 5:17 pm
  • 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?

    December 10, 2018 at 8:35 am
  • 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”

    July 31, 2019 at 11:28 am

Comments are closed.

Use Percona's Technical Forum to ask any follow-up questions on this blog topic.