logging with haproxy

assuming debian11 (rsyslog to sysklogd)

warning

note /dev/log is reachable even when chroot is enabled

ls -lF /var/lib/haproxy/dev/log

this is thanks to the rsyslog AddUnixListenSocket setting

cat /etc/rsyslog.d/49-haproxy.conf

the default setup prints to /var/log/haproxy.log by default

so with rsyslog on debian11, everything is fine already – however if you want GNU syslogd or sysklogd, you need to send logs through UDP

syslogd setup

vi /etc/syslog.conf
local0.*                        -/var/log/haproxy.log

haproxy setup

cd /etc/haproxy/
vi haproxy.cfg

we need the logs to be sent to local syslog daemon

    log 127.0.0.1 local0

ready to go

    systemctl status rsyslog
    systemctl status haproxy

tail -F /var/log/haproxy.log

resources

https://www.haproxy.com/blog/introduction-to-haproxy-logging

https://www.haproxy.com/documentation/haproxy-configuration-manual/latest/#8

https://www.haproxy.com/documentation/haproxy-configuration-manual/latest/#4-log-format

https://www.haproxy.com/documentation/haproxy-configuration-manual/latest/#4-log-format-sd

https://www.haproxy.com/documentation/haproxy-configuration-manual/latest/#4-log-tag

https://serverfault.com/questions/937035/what-is-the-meaning-of-these-haproxy-configuration-lines

rsyslog unix socket

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/load_balancer_administration/s1-haproxy-logging#doc-wrapper ==> rsyslog & path to chroot /dev/log

json

https://www.haproxy.com/blog/haproxy-log-customization

https://ahmadallish.substack.com/p/json-logging-in-haproxy-the-right-way-3636297d2d49

FW https://medium.com/thirddev/json-logging-in-haproxy-the-right-way-3636297d2d49


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun