How to keep haproxy log messages out of /var/log/syslog
Solution 1:
You could also do the following which will make it so they don't go in any other logs:
local0.* -/var/log/haproxy.log
& ~
The & ~
means not to put what matched in the above line anywhere else for the rest of the rules.
Solution 2:
The use of & ~
was deprecated in v7 of rsyslogd, and you're encouraged to use & stop
instead. You can read more about it in this section of the v7compatibility page.
omruleset and discard (~) action are deprecated
Both continue to work, but have been replaced by better alternatives.
The discard action (tilde character) has been replaced by the “stop” RainerScript directive. It is considered more intuitive and offers slightly better performance.
The omruleset module has been replaced by the “call” RainerScript directive. Call permits to execute a ruleset like a subroutine, and does so with much higher performance than omruleset did. Note that omruleset could be run off an async queue. This was more a side than a desired effect and is not supported by the call statement. If that effect was needed, it can simply be simulated by running the called rulesets actions asynchronously (what in any case is the right way to handle this).
Note that the deprecated modules emit warning messages when being used. They tell that the construct is deprecated and which statement is to be used as replacement. This does not affect operations: both modules are still fully operational and will not be removed in the v7 timeframe.
So for HAProxy something like this instead:
$ more /etc/rsyslog.d/haproxy.conf
local2.* /var/log/haproxy.log
& stop
As to how it works, the & stop
tells rsyslogd to discard any additional messages that matched the previously matched rules up to this point. To guarantee that this rule is picked up early on, you can change the name of the file from /etc/rsyslog.d/haproxy.conf
to /etc/rsyslog.d/00-haproxy.conf
.
Solution 3:
Ok, I figured it out. This is what my /etc/rsyslog.d/20-haproxy.conf
looks like:
$ModLoad imudp
$UDPServerRun 514
local0.* -/var/log/haproxy_0.log
local1.* -/var/log/haproxy_1.log
I changed the line in 50-default.conf
to:
*.*;auth,authpriv,local0,local1.none -/var/log/syslog
And now it seems to be doing what I want.