While installing the newest HAProxy on Debian 12, I discovered that the default global log configuration was ignored.
Specifically, facilities are ignored, all log messages use the daemon facility.
Setting a specific log format did not help.
- HAProxy version 3.0.0-1~bpo12+1 2024/06/01
- rsyslogd 8.2302.0
- Debian 12.5 bookworm
haproxy.cfg
global
# default provided config
# log /dev/log local0
# log /dev/log local1 notice
# attempt to force extended log format
log /dev/log format rfc5424 local0
log /dev/log format rfc5424 local1 notice
# untouched config below this line; no backends, no listeners nothing extra added
For many years I’ve been using these rsyslog config that was working:
$AddUnixListenSocket /var/lib/haproxy/dev/log
if $syslogfacility-text == 'local0' and $programname startswith 'haproxy' then /var/log/haproxy.admin.log
&stop
if $syslogfacility-text == 'local1' and $programname startswith 'haproxy' then /var/log/haproxy.log
&stop
I’ve noticed that apt provides rsyslog config /etc/rsyslog.d/49-haproxy.conf:
$AddUnixListenSocket /var/lib/haproxy/dev/log
:programname, startswith, "haproxy" {
/var/log/haproxy.log
stop
}
I decided to enhance it
#$DebugFile /var/log/rsyslog.debug
#$DebugLevel 2
input(
type="imuxsock"
Socket="/var/lib/haproxy/dev/log"
)
if ($programname startswith "haproxy") then {
if ($syslogfacility-text == "local0") then {
action(type="omfile" File="/var/log/haproxy.admin.log")
} else if ($syslogfacility-text == "local1") then {
action(type="omfile" File="/var/log/haproxy.log")
### added for troubleshooting purposes
} else if ($syslogfacility-text == "daemon") then {
action(type="omfile" file="/var/log/haproxy.daemon.log")
# was catching everything, until I added case for the `daemon` facility
} else {
action(type="omfile" file="/var/log/haproxy.log")
}
}
What am I doing wrong?
Why is HAProxy not “splitting” logs into multiple facilities “streams”?
Maybe I do not understand something about HAProxy logging, and real daemon messages always use the daemon facility and ignore globa.log config?
Maybe this is a bug in HAProxy?
I’ve tested rsyslog is catching all facilities just, including messages with facilities sent to “haproxy” syslog socket.
logger -u /var/lib/haproxy/dev/log -t test -p local1.info "This is a test log message"
# received message just fine this tmp filter
#if ($syslogfacility-text == "local1") then {
# action(type="omfile" File="/var/log/troubleshoot.log")
#}
1 post - 1 participant