How to configre Log in Haproxy


#1

Hi Community,

I am a newbee just trying to use HAproxy, so please forgive me if I ask some dump questions.

I was trying to config the HAproxy log for the future use, while I keep get the same error: [ALERT] 233/183043 (921) : sendto logger #0 failed: No such file or directory (errno=2)

The system is Ubuntu 14.04, and Haproxy version is 1.4.24

The global setting in /etc/haproxy/haproxy.cfg is:
global
log /dev/log local0
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon

And the haproxy.conf in /etc/rsyslog.d/ is:

Create an additional socket in haproxy’s chroot in order to allow logging via

/dev/log to chroot’ed HAProxy processes

#$AddUnixListenSocket /var/lib/haproxy/dev/log
$AddUnixListenSocket /dev/log

local0.* /var/lib/haproxy/dev/log/haproxy_0.log
#local1.* ~/var/log/haproxy/dev/log/haproxy_1.log

Send HAProxy messages to a dedicated logfile

#if $programname startswith ‘haproxy’ then /var/log/haproxy.log
if $programname startswith ‘haproxy’ then /var/lib/haproxy/dev/log/haproxy_0.log
&~

I already create the log file inside the path /var/lib/haproxy/dev/log
root@e77355263351:/etc/haproxy# ls /var/lib/haproxy/dev/log/
haproxy_0.log local0 local1

I think the problem is either because the file path incorrect, or the file permission is not correct. But for some reason I just can’t figure it out. So I just post here to see if somebody could help and save my potential hour spent. I will really appreciate the help!

Thanks in advance!

Qing


#2

Opps, sorry for the message format, dont realize the size mess up when I type in the message!