Deepali Mittal
Deepali Mittal

Reputation: 1032

Haproxy logs not getting created in ubuntu 16.04

With same configuration haproxy logs were logged in /var/log/haproxy.log in ubuntu 14.04, but when moved to ubuntu 16.04 it is failing. I checked different things mentioned in https://serverfault.com/questions/738501/how-to-fix-simple-haproxy-logging/738508 or https://serverfault.com/questions/488967/haproxy-not-logging.

Nothing seems to work. Not able to find the fix whether it is due to systemd changes made in ubuntu 16.04.

haproxy.cfg has :

global
    chroot /var/lib/haproxy
    log /dev/log  local0
    log /dev/log  local1 notice

defaults
    log global

/etc/rsyslog.d/49-haproxy.conf :

# 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

# Send HAProxy messages to a dedicated logfile
if $programname startswith 'haproxy' then /var/log/haproxy.log
&~

Upvotes: 0

Views: 4765

Answers (1)

David MacCallum
David MacCallum

Reputation: 221

I struggled with what I suspect is the same issue. I was expecting to find HTTP access logs in /var/log/haproxy.log. Here is how I fixed my issue and what I discovered.

Frontend logging

To log HTTP requests I have the following config:

default
  mode http
  option  httplog
  option  dontlognull

frontend www-http
  bind *:80
  log /dev/log local0

The log directive needs to be set on the frontend to get HTTP access logs.

The dontlognull option is useful for filtering out TCP probes.

Global logging

The log directive under the global config heading is for system errors, start/stop, etc.. (more info)

Upvotes: 2

Related Questions