Enabling Logging
To enable logging in HAProxy Enterprise, follow these steps:
-
Add a
log
line to theglobal
section in your configuration file. The following lines configure the access (frontend traffic) log on thesyslog local0
facility and the admin (backend server status) log on thesyslog local1
facility.global # log all events to a remote syslog server log 127.0.0.1 local0 # log 'notice' level events and above to a remote syslog server log 127.0.0.1 local1 notice
The
log
directive takes the following parameters:the IP address of your syslog server or the path to a local syslog UNIX socket (i.e. /dev/log)
an optional
len <length>
, which changes the default length of 1024 characters per log linean optional
format <format>
, which you can set to rfc3164 (default), rfc5424, short, or rawan optional
sample <range>:<size>
to capture a sample of the logs (i.e. 1 out of 3 would besample 1:3
)the facility code (usually local0 or, if that is already used, local1)
the level of severity; choose one of emerg, alert, crit, err, warning, notice, info, or debug. Omit severity to log all events.
-
In your
frontend
ordefaults
section, add alog global
directive, which uses the settings you defined with thelog
directive in theglobal
section.defaults log global
Next up
Setting Log Levels