Search

5.7. Logging HAProxy Messages to rsyslog

download PDF
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.
    defaults
        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.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.