Overview
HAProxy Enterprise stores logs in the /var/log/hapee-1.9 directory.
It stores lb-access log files, which record information about client connections and requests, and lb-admin log files, which record load balancer events such as when a proxy starts or stops.
Enable logging
To enable logging, follow these steps:
-
Add a
log
line to theglobal
section in your configuration file.global # log all events to the local syslog UNIX socket log
/dev/loglocal0 # log 'notice' level events and above to a remote syslog server log 127.0.0.1 local1 noticeThe
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 verbosity; choose one of emerg, alert, crit, err, warning, notice, info, or debug. Leave this off to record 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
Default access log format
By default, HAProxy Enterprise logs a predefined set of information about each TCP connection in the access logs.
Jan 27 21:15:06 localhost hapee-lb[2901]: Connect from 192.168.50.1:61459 to 192.168.50.25:80 (fe_main/HTTP)
The information includes:
Field | Example |
---|---|
the PID of the HAProxy Enterprise process | hapee-lb[2901] |
the text "Connect from" followed by the client's source IP address and port | Connect from 192.168.50.1:61459 |
the text "to" followed by the destination IP address and port | to 192.168.50.25:80 |
the name of the frontend that received the request and the mode (e.g. HTTP) | (fe_main/HTTP) |
TCP access log format
If you are using mode tcp
in your frontend
and backend
sections, then you can collect more detailed logs by adding option tcplog
to both sections or to your defaults
section, as shown below:
defaults
mode tcp
option tcplog
After restarting the load balancer, more detailed logs are captured.
Jan 27 21:22:53 localhost hapee-lb[3042]: 192.168.50.1:61535 [27/Jan/2021:21:22:10.944] fe_main be_servers/s1 1/0/42404 2895 cD 1/1/0/0/0 0/0
The information includes:
Field | Example |
---|---|
the PID of the HAProxy Enterprise process | hapee-lb[3042] |
the client's source IP address and port | 192.168.50.1:61535 |
the date that the connection was accepted | [27/Jan/2021:21:22:10.944] |
the name of the frontend that received the request | fe_main |
the name of the backend that received the request, followed by a slash and the name of the server | be_servers/s1 |
three numbers separated by slashes:
| 1/0/42404 |
the number of bytes read | 2895 |
the termination state, which is a two-digit letter code that describes how the connection closed | cD |
five numbers separated by slashes:
| 1/1/0/0/0 |
two numbers separated by a slash:
| 0/0 |
HTTP access log format
If you are using mode http
in your frontend
and backend
sections, then you can collect more detailed logs by adding option httplog
to both sections or to your defaults
section, as shown below:
defaults
mode http
option httplog
After restarting the load balancer, more detailed logs are captured.
Jan 27 21:52:56 localhost hapee-lb[3098]: 192.168.50.1:61818 [27/Jan/2021:21:52:56.086] fe_main be_servers/s1 0/0/1/1/2 200 517 - - ---- 1/1/0/0/0 0/0 "GET / HTTP/1.1"
The information includes:
Field | Example |
---|---|
the PID of the HAProxy Enterprise process | hapee-lb[3098] |
the client's source IP address and port | 192.168.50.1:61818 |
the date that the connection was accepted | [27/Jan/2021:21:52:56.086] |
the name of the frontend that received the request | fe_main |
the name of the backend that received the request, followed by a slash and the name of the server | be_servers/s1 |
five numbers separated by slashes:
| 0/0/1/1/2 |
HTTP status code | 200 |
the number of bytes read | 517 |
captured request cookie values (requires using the older | - |
captured response cookie values (requires using the older | - |
the termination state, which is a four-digit letter code that describes how the connection closed | ---- |
five numbers separated by slashes:
| 1/1/0/0/0 |
two numbers separated by a slash:
| 0/0 |
the HTTP request line | "GET / HTTP/1.1" |
Next up
Log Custom Data