5

How does one adjust logging level or disable logging altogether for specific backends in HAProxy?

In the example below, both directives "http-request set-log-level err" and "no log" seem to have no effect - the logs are swamped with lines of successful HTTP status 200 OK records.

global
  log /dev/log local0
  log /dev/log local1 notice

...

defaults
  log global
  mode http

  option httplog
  option dontlognull

...

backend static
  http-request set-log-level err
  no log
AlexMinza
  • 73
  • 1
  • 7
  • `dontlognormal` might do what you want. Can't be used in the backend section though. – wurtel Dec 08 '14 at 10:35
  • @wurtel that's correct - `option dontlog-normal` cannot be set at the backend level and impacts all backends linked to a frontend with this option set. http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#4-option%20dontlog-normal – AlexMinza Dec 08 '14 at 16:51

1 Answers1

11

Courtesy of meineerde in #haproxy on Freenode:

You can disable logging in the frontend, using the same conditions by which you pick the backend.

http-request set-log-level silent if static
use_backend static                if static

This must happen in the frontend section, because the logging decision must be made at this stage.

Felix Frank
  • 3,093
  • 1
  • 16
  • 22