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
.
- In the
global
section of the HAProxy configuration file, use thelog
directive to target the/dev/log
socket.log /dev/log local0
- Update the
frontend
,backend
, andlisten
proxies to send messages to thersyslog
service you configured in theglobal
section of the HAProxy configuration file. To do this, add alog global
directive to thedefaults
section of the configuration file, as shown.defaults log global option httplog
- If you are running HAProxy within a
chrooted
environment, or you let HAProxy create achroot
directory for you by using thechroot
configuration directive, then the socket must be made available within thatchroot
directory. You can do this by modifying thersyslog
configuration to create a new listening socket within thechroot
filesystem. To do this, add the following lines to yourrsyslog
configuration file.$ModLoad imuxsock $AddUnixListenSocket PATH_TO_CHROOT/dev/log
- 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.