# HAProxy not logging



## Raddinox (Sep 5, 2020)

I have been running FreeBSD with HAProxy as my reverse proxy for a while. Recently I got my ELK stack up and running, so now I want to send my HAProxy log to logstash using filebeats.

But now I noticed that my HAProxy instance is not logging to my log file, /var/log/haproxy.log

/usr/local/etc/haproxy.conf

```
lobal
      maxconn 4096
      user www
      group www
      pidfile /var/run/haproxy.pid
      log /dev/log local0 debug
      daemon
      tune.ssl.default-dh-param 2048

defaults
      mode http
      log global
      option httplog
      timeout connect 5s
      timeout client 30s
      timeout server 30s
...
```

/usr/local/etc/syslog.d/haproxy.conf

```
# HAProxy log
local0.*            /var/log/haproxy.log
```

I do receive messages when HAProxy is starting/stopping in /var/log/messages. But there is no /var/log/haproxy.log, using debug I thought there should be something logging, but I get nothing.

I recently updated my FreeBSD server to 12.1-RELEASE-p8 and I am running HAProxy to version 2.1.7 2020/06/09

So what am I missing to log the traffic going through my HAProxy server?


----------



## T-Daemon (Sep 6, 2020)

I don't use HAProxy, found the following documentation ( assuming it's still valid, for summarized FreeBSD HAProxy logging configuration skip the documentation, go to "ancient mails" at the end of this posting ) :

haproxy(1)

```
LOGGING
       Since  HAProxy  can  run     inside     a  chroot,  it    cannot reliably    access
       /dev/log.  For this reason, it uses the UDP protocol to send  its  logs
       to  the    server,     even if it is the local server. People    who experience
       trouble receiving logs should ensure that their syslog  daemon  listens
       to the UDP socket.
```

The followings are excerpts from the Management Guide, 8. Logging, please read the complete text to that section for more context.


```
For logging, HAProxy always relies on a syslog server since it does not perform
any file-system access. The standard way of using it is to send logs over UDP
to the log server (by default on port 514). Very commonly this is configured to
127.0.0.1 where the local syslog daemon is running, but it's also used over the
network to log to a central server.
....

It is recommended to add the following directive to the "global" section to
make HAProxy log to the local daemon using facility "local0" :

      log 127.0.0.1:514 local0
```
And these ancient mails:



			'Re: HAproxy FreeBSD no Logging?' - MARC
		



			'Re: HAproxy FreeBSD no Logging?' - MARC


----------



## Raddinox (Sep 6, 2020)

Awesome, it's working now  

My syslogd did not listen to the UDP port, So the line _syslogd_flags="-b localhost -C"_ in /etc/rc.conf was needed. Then I changed my haproxy.conf to send logs to 127.0.0.1 and not /dev/null


----------

