I have configured rsyslog (CentOS 6.3) adding the -c 0 -r options and the line

local2.* /var/log/haproxy.log 

and restarted rsyslog but all that happens is an haproxy.log gets created. It is never written to.

Not quite sure how to troubleshoot this.

Below is my haproxy.cfg file. Nothing else is configured to use local2 according to grepping for it in rsyslog.conf. My haproxy config is basically the default, just trying to get logging working first.

  • Please reformat your question so that it is readable. – daff Mar 18 '13 at 18:01

I believe haproxy only have syslog logging via UDP. What is your log config line in haproxy.cfg?

Is it?

log local2

If so, you'll need to enable the UDP server modules in the rsyslog configuration by uncommenting:

$ModLoad imudp.so
$UDPServerRun 514

Tip: I run the following command on all my haproxy servers:

sudo sed -i 's/#$ModLoad imudp.so/$ModLoad imudp.so/' /etc/rsyslog.conf; sudo sed -i 's/#$UDPServerRun 514/$UDPServerRun 514/' /etc/rsyslog.conf; sudo service rsyslog restart
  • Just out of curiosity, for a dummy like me, who doesn't know that.. How would you recommend troubleshooting an issue like that? How could I have seen that the UDP logging info was being blocked (aside from reading the rsyslog man pages)? – user160910 Mar 18 '13 at 19:20
  • It was a while back for this problem (over a year ago), and I believe I solved it after reading one or some of the following: - linuxadminzone.com/… - kvz.io/blog/2010/08/11/haproxy-logging Definitely read and re-read the haproxy config and rsyslog man pages. Knowing that it's UDP to syslog logging from haproxy manual, I would have done a tcpdump to find who's at fault (whether haproxy or rsyslog) and go from there. Command would be: tcpdump -i lo udp port 514 – martian111 Mar 18 '13 at 21:26
  • seems relevant: anhlqn.blogspot.com/2014/01/… – Erik Kaplun Oct 12 '14 at 22:48
  • I'm using rsyslog to try to gather haproxy logs, I have edited my conf files like you did, iptables is disabled, the log file is created; but nothing is written inside, even after a restart of both HAProxy and rsyslog ... I also have the good configuration in /etc/logrotate.d. I checked over and over the configuration, i'm in the same channel (local2) and I'm restrincting all this to the local loop ( Did I miss something ? thx – Alex Apr 11 '17 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy