Send HAProxy logs to remote host

I Wanted to send my HAProxy logging to a remote server so my loadbalancer didn't have to deal with logging.

In the haproxy.conf I changed this line:

       log local0

To this:

        log local0

All logging for HAProxy is now send to my logging server after a restart/reload of HAProxy.

This is how my logging server receives the logs send from HAProxy:

Mar 10 12:02:05 lb01 haproxy[27980]: <ip>:47970 [10/Mar/2016:12:02:05.645] http-proxy httpweb02/web02 0/0/0/1/1 200 441 - - ---- 3/1/0/0/0 0/0 "GET /server-status?auto HTTP/1.1"

I Want to remove these lines from the default syslog file on my logging server and send to a seperate file.

On the logging server, create the following file:


With the following content:

# HAProxy logging
:syslogtag, startswith, "haproxy" /data/log/haproxy/haproxy.log
& ~

This tells the rsyslog daemon to filter all messages starting with "haproxy" from the syslog tag and send it to my custom logging location: /data/log/haproxy/haproxy.log

The "& ~" line is not to log it to any default location like messages or syslog files.

Restart the rsyslog daemon on the logging server to activate this rsyslog filter.