Friday, October 19, 2018

HAProxy logging on RHEL7

How to configure RHEL7 rsyslog for haproxy logging.

Problem: The haproxy config (/etc/haproxy/haproxy.cfg) reports how to enable logs; however, this seems to be syslogd specific which is not what is running in RHEL7

Solution: enable logging via rsyslog configs:
Modify /etc/rsyslog.conf to include:

# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
# Provides TCP syslog reception
$ModLoad imtcp $InputTCPServerRun 514

*note: maybe only UDP or maybe only TCP is needed.

Modify /etc/rsyslog.d/listen.conf

local2.* /var/log/haproxy.log

*note: this could just as easily be /etc/rsyslog.d/haproxy.conf, i chose the prior only because it pre-existed.

*note: local2 is the default in haproxy, but this could be changed if desired.

*note: the -r is required, the -m 0 is not, but meant to reduce junk. If it is looking up DNS and you don’t want, then add -x

Now sudo systemctl restart rsyslog and tail -f /var/log/haproxy.log to see the records.

As always, good luck!

resources used:


Written with StackEdit.

No comments:

Post a Comment

Comments, Suggestions or "Thank you's" Invited! If you have used this info in any way, please comment below and link/link-back to your project (if applicable). Please Share.
I accept Bitcoin tips of ANY amount to: 1GS3XWJCTWU7fnM4vfzerrVAxmnMFnhysL
I accept Litecoin tips of ANY amount to: LTBvVxRdv2Lz9T41UzqNrAVVNw4wz3kKYk