Haproxy not logging with rsyslog

I want to configure HTTP logging in HAProxy, and I'm having trouble getting it to correctly display requests.

Here is the configuration corresponding to HAProxy:

global log /dev/log local0 log /dev/log local1 notice maxconn 200000 tune.ssl.default-dh-param 2048 user haproxy group haproxy daemon stats socket /tmp/sock1 user root group root mode 777 level admin defaults log global mode http option httplog option dontlognull option httpclose retries 3 option redispatch maxconn 200000 backlog 20000 timeout connect 5s timeout client 50s timeout server 180000 balance roundrobin cookie SERVERID rewrite 

Here is the /etc/rsyslog.d/haproxy.conf file:

 # Create an additional socket in haproxy chroot in order to allow logging via # /dev/log to chroot'ed HAProxy processes $AddUnixListenSocket /var/lib/haproxy/dev/log # Send HAProxy messages to a dedicated logfile if $programname startswith 'haproxy' then /var/log/haproxy.log &~ 

I restarted both haproxy and rsyslogd after making the correct changes to make sure they were raised. The file /var/log/haproxy.log is not even created. Any help would be appreciated.

+6
source share
3 answers

The rsyslog configuration assumes chroot'd HAProxy, which does not match the haproxy configuration. Or chroot HAProxy, adding a line

  chroot /var/lib/haproxy 

for global haproxy configuration structure or change socket location rsyslog creates

 $AddUnixListenSocket /dev/log 
+3
source

In global change / add:

 global chroot /var/lib/haproxy log /var/lib/haproxy/dev/log local0 log /var/lib/haproxy/dev/log local1 notice ... rest of your file 
+1
source

I had the same issue on Ubuntu 16.04. A trial restart of haproxy and syslog and /var/log/haproxy.log has not yet been created.

In the end, I just restarted the server, and the file / var / log / haproxy.log was created at boot time.

+1
source

Source: https://habr.com/ru/post/977373/


All Articles