From becb5152b9c39031e5ea2c36bdf21fd3b0596d59 Mon Sep 17 00:00:00 2001 From: Guy Elkayam Date: Tue, 2 Aug 2022 13:58:20 +0300 Subject: [PATCH] Fix wrong log routing * Avoid haproxy logs that are echoed from systemd-journal (errors getting send again as severity 6) by limiting source to UDP input * Correct scoping to avoid unreachable code due to stop, and errors not logged to correct log * Fix indentation --- SOURCES/haproxy.syslog.el7 | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/SOURCES/haproxy.syslog.el7 b/SOURCES/haproxy.syslog.el7 index 05d1337..29e262a 100644 --- a/SOURCES/haproxy.syslog.el7 +++ b/SOURCES/haproxy.syslog.el7 @@ -5,14 +5,17 @@ $UDPServerRun 514 $template HAProxy,"%TIMESTAMP% %syslogseverity-text:::UPPERCASE%: %msg:::drop-last-lf%\n" $template HAProxyAccess,"%msg%\n" -if $programname startswith 'haproxy' then { - if $syslogseverity == 6 then - action(type="omfile" file="/var/log/haproxy/access.log" template="HAProxyAccess") - stop - if $syslogseverity <= 3 then - action(type="omfile" file="/var/log/haproxy/error.log" template="HAProxy") - stop - if $syslogseverity <= 5 then - action(type="omfile" file="/var/log/haproxy/status.log" template="HAProxy") - stop -} \ No newline at end of file +if ($programname startswith 'haproxy' and $inputname == 'imudp') then { + if $syslogseverity == 6 then { + action(type="omfile" file="/var/log/haproxy/access.log" template="HAProxyAccess") + stop + } + if $syslogseverity <= 3 then { + action(type="omfile" file="/var/log/haproxy/error.log" template="HAProxy") + stop + } + if $syslogseverity <= 5 then { + action(type="omfile" file="/var/log/haproxy/status.log" template="HAProxy") + stop + } +}