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

SYSLOGD_OPTIONS="-m 0 -r"
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.

Note: There are many and more complex settings, this is just a most basic configuration.

As always, good luck!

~~
resources used:

  1. https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_MRG/1.3/html/Realtime_Tuning_Guide/sect-Realtime_Tuning_Guide-General_System_Tuning-syslog_tuning_tips.html
  2. https://linux.die.net/man/8/rsyslogd

Please consider crypto tipping:
  

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