Call Us! 1-800-383-5193
Call Us! 1-800-383-5193
Call Us! 1-800-383-5193

Need Help?

Emergency Response Time custom

Our experts have had an average response time of 12.45 minutes in December 2020 to fix urgent issues.

We will keep your servers stable, secure and fast at all times for one fixed price.

HAProxy Logging Rsyslog on CentOS 8 – How to Set up

by | Jan 6, 2021

Need to set up HAProxy Logging Rsyslog on CentOS 8?

At Bobcares, we often get similar requests from our customers as part of Server Management Services.

Today let’s see how our Support Engineers do this setup for our customers.

How To Configure HAProxy Logging Rsyslog on CentOS 8?

High Availability Proxy or HAProxy is a widely used TCP and HTTP-based proxy server that runs on Linux, Solaris, and FreeBSD.

HAProxy Logging Rsyslog

On most of the CentOS 8 installations, HAProxy is not set up in a way to write its log output to a file by default.

Let’s see how our Support Engineers configure this with some quick and easy steps.

Steps to follow are given below:

1. Installing and Enabling HAProxy

First, run the following dnf command:

$ sudo dnf install haproxy

Then we have to enable and start it using the systemctl command:

$ sudo systemctl enable haproxy.service

We will get the following output:

Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/haproxy.service.

Now we can start the service to ensure that it runs with a default configuration using the following command.

$ sudo systemctl start haproxy.service

To check the status of the service we can use the following command:

$ sudo systemctl status haproxy.service

Once we ensure that HAProxy is enabled and running, we can continue to configure HAProxy’s logging directives.

2. Configuring HAProxy Logging Directives

To configure HAProxy’s logging directives first, we have to open /etc/haproxy/haproxy.cfg in vi or your preferred editor:

$ sudo vi /etc/haproxy/haproxy.cfg

Then find the line “log local2” and comment it out by adding a # character to the beginning of the line, as given in the following example:

# /etc/sysconfig/syslog
# local2.* /var/log/haproxy.log
#log local2

chroot /var/lib/haproxy
pidfile /var/run/

Now we have to add a line directly after the commented out line with the following contents:

log /dev/log local0

The log /dev/log local0 line will create a file inside that directory that Rsyslog will use to collect log entries from.

After that save the changes made in  /etc/haproxy/haproxy.cfg

The final step is to create the /var/lib/haproxy/dev directory since it does not exist by default.

We can create the directory using the mkdir command and then restart HAProxy:

$ sudo mkdir /var/lib/haproxy/dev
$ sudo systemctl restart haproxy.service


3. Configuring Rsyslog to Collect HAProxy Logs

To collect logs from the HAProxy service, first, open a new file /etc/rsyslog.d/99-haproxy.conf using vi.

$ sudo vi /etc/rsyslog.d/99-haproxy.conf

Then add the following lines into the file:

$AddUnixListenSocket /var/lib/haproxy/dev/log

# Send HAProxy messages to a dedicated logfile
:programname, startswith, "haproxy" {


Once we complete editing /etc/rsyslog.d/99-haproxy.conf,  we have to save the changes made.

We have now configured HAProxy to Log Rsyslog.

[Need assistance for this setup? We are happy to help you!]


In this article, we saw how our Support Techs set up HAProxy Logging Rsyslog with some quick and easy steps.


Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.


var google_conversion_label = "owonCMyG5nEQ0aD71QM";


Submit a Comment

Your email address will not be published. Required fields are marked *

server management

Spend time on your business, not on your servers.


Or click here to learn more.