HAProxy Logging

KNNX Corp.
KNNX Corp.
Published in
3 min readOct 15, 2019

--

HAProxy Logging

Have you ever wondered, what if we have to debug an issue using HAProxy® software load balancer without logs or with the messy logs where we have to filter out the parts which are our own?

Recently I configured HAProxy in our environment. Things were going well but I needed to troubleshoot an issue. I immediately checked the logs and I was shocked that there were no logs for HAProxy because by default logging in HAProxy was disabled.

It turns out, enabling logging within HAProxy for your environment can quickly lead to space becoming a scarce resource. This is due to the fact that most of the time HAProxy is set to use local0 facility. This leads to writing logs to a bunch of files in /var/log.

As a result, I am going to show you how to use rsyslog, which lets you narrow down those logs to a more appropriate location and format.

Now let’s get started.

Enabling logging and specifying write location

Logs can be enabled by adding the below line in the config of HAProxy.

log 127.0.0.1 local0

Lets break down what the above code means:

  • log — adds a global syslog server.
  • 127.0.0.1 — address where are logs sent
  • local 0 — name of the logs

--

--

KNNX Corp.
KNNX Corp.

KNNX is a global leader in Distributed Ledger Technology and Enterprise Products. To learn more, head over to: https://www.knnx.com/