On 5/4/2016 5:30 PM, Chris White wrote:
> I am trying to stop backend health check error messages from being
> logged to the system console.
<snip>
> But I am still seeing error messages logged when a backend server goes down
<snip>
> 2016 May 4 23:11:14 devtest0 backend web has no server available!
It's your syslog server that's actually logging to the console,
according to the rules in your syslog config. It does this based on the
severity of the message -- it probably has all "emerg" severity messages
going to the console. Most people want to be notified of emergencies
VERY quickly, so this is a fairly standard setup found by default in
syslog daemons. Haproxy logs at the emerg level when a whole backend
goes down. It does not log individual servers going down at that
severity, but if you have a backend with only one server, it will *seem*
like it's notifying you about the server going down.
You can stop it completely by reconfiguring the syslog server to exclude
the facility being used by haproxy from console notifications. Exactly
how to do this may be different for different syslog servers, and is
outside the scope of this mailing list.
I ran into a similar situation. It makes complete sense for a console
notification to happen when a *PRODUCTION* backend goes down, but I do
not want to see that information for dev or staging back ends. Those
back ends typically only have one server, and that server typically gets
bounced a LOT, so the entire backend goes down quite frequently, making
for a very noisy console.
So I asked the fine folks here what to do about it, and implemented
their suggestion. Now I only get notified on the console if all servers
in a production backend are down -- which is indeed an emergency that
needs immediate attention. Because production websites have more than
one server, this is a rare occurrence.
This is what I have by default for logging:
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
This logs *all* messages to local0, but excludes "info" and "debug" when
logging to local1. My syslog config maps local0 to
/var/log/debug-haproxy and local1 to /var/log/haproxy.
In the backends where I do not want console notifications, I have this:
no log
log 127.0.0.1 local0 notice err
What this does is first turn off all configured default logging, then
set up logging for all severity levels between err and notice to local0,
my debug destination. The emerg severity notifications are outside this
range, so they are not logged at all for that backend.
Thanks,
Shawn