Enable or fix logging for HAProxy load balancer

by jagbir on March 21, 2009

After configuration of HAProxy to balance web traffic, I’ve noticed that HAProxy is not generating any logs in my server. Due to its load balancer role, logging is vital to diagnose any issue that might come in future.

In its default config, HAProxy send logs to a syslog facility: local0, via a socket connection. By default, your syslog configuration probably doesn’t accept socket connections, and even doesn’t have a local0 facility, so you have no HAProxy log. If you want it, configure syslog to accept TCP connections by adding -r to syslogd parameters.

On a RedHat/CentOS server, edit the value of SYSLOGD_OPTIONS in /etc/sysconfig/syslog:


On a Debian/Ubuntu server, edit the value of SYSLOGD in /etc/default/syslogd:


Then set up syslog facility local0 and direct it to file /var/log/haproxy.log or your desired location by editing /etc/syslog.conf:

local0.* /var/log/haproxy.log

finally, restart syslog service to apply changes:

$ /etc/init.d/syslog restart

You can see that HAProxy logging is started.

Other useful article on this blog that you may like to read:
* Configure HAProxy for content switching
* 5 Steps to secure your Production Linux Server
* Ensuring secure access to your Production Linux Server
* Bash script to backup essential log files in Linux Server

  • http://xtgo.net Curtis

    Thank you. This is exactly what I needed. Worked perfectly except to restart syslog in ubuntu the command is:

    “/etc/init.d/sysklogd restart”

    • http://linuxadminzone.com jagbir

      Thanks Curtis for your comment and tip.

  • malena

    just what i needed thanks

    • http://linuxadminzone.com jagbir

      Thanks Malena for comment. Glad to know it helped you.

  • http:/harry.sufehmi.com sufehmi

    Hi, thanks for the excellent guide.

    Newer versions of Ubuntu, however, uses rsyslog – not syslog.

    The guide to setup HAproxy logging for rsyslog can be read here :



  • Pingback: Proxy Blog

  • Pingback: HAProxy 学习笔记1 | 南龙的小站

  • sanjiv singh

    Thanks a lot, That’s something i needed.

    Now i can see all log in log file.

    # tail -220f /var/log/haproxy.log

    Nov 12 04:35:13 haproxy[4143]: Stopping frontend httpid in 0 ms.

    Nov 12 04:35:13 haproxy[4143]: Proxy stats stopped (FE: 0 conns, BE: 0 conns).

    Nov 12 04:35:13 haproxy[4143]: web-server stopped (FE: 0 conns, BE: 0 conns).

    Nov 12 04:35:13 haproxy[4143]: Proxy httpid stopped (FE: 0 conns, BE: 0 conns).

    but i want to configure Haproxy for logs in HTTP log format.But i
    gone through manual , i did following changes in HAproxy configuration.

    # haproxy.cfg


    backend dmb-dmbadminweb-server

    balance roundrobin

    option redispatch

    option httpclose

    option forwardfor

    server server-A : weight 1 maxconn 20000 check inter 4000

    frontend httpid

    bind *:2020

    mode http

    option httplog

    log global

    default_backend web-server


    when I’m hitting web-server via Haproxy , it is only logging only as i shon above.

    I am expecting logs like :

    Feb 6 12:14:14 localhost

    haproxy[14389]: [06/Feb/2009:12:14:14.655] http-in

    static/srv1 10/0/30/69/109 200 2750 – – —- 1/1/1/1/0 0/0 {1wt.eu}

    {} “GET /index.html HTTP/1.1″

  • Pingback: haproxy einrichten | Notitzblock

Previous post:

Next post: