Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

5.7. Logging HAProxy Messages to rsyslog

You can configure your system to log HAProxy messages to rsyslog by writing to the /dev/log socket. Alternately you can target the TCP loopback address, however this results in slower performance.
The following procedure configures HAProxy to log messages to rsyslog.
  1. In the global section of the HAProxy configuration file, use the log directive to target the /dev/log socket.
    log /dev/log local0
  2. Update the frontend, backend, and listen proxies to send messages to the rsyslog service you configured in the global section of the HAProxy configuration file. To do this, add a log global directive to the defaults section of the configuration file, as shown.
        log global
        option httplog
  3. If you are running HAProxy within a chrooted environment, or you let HAProxy create a chroot directory for you by using the chroot configuration directive, then the socket must be made available within that chroot directory. You can do this by modifying the rsyslog configuration to create a new listening socket within the chroot filesystem. To do this, add the following lines to your rsyslog configuration file.
    $ModLoad imuxsock
    $AddUnixListenSocket PATH_TO_CHROOT/dev/log
  4. To customize what and where HAProxy log messages will appear, you can use rsyslog filters as described in Basic Configuration of Rsyslog in the System Administrator's Guide.