haproxy not logging
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.
Solution 1:
I believe haproxy only have syslog logging via UDP. What is your log config line in haproxy.cfg?
Is it?
log 127.0.0.1 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