HAProxy Enterprise Documentation 2.5r1

Logging without Waiting for Session Termination

By default, logs are emitted when the session terminates, that is, when all log values are finalized. Capturing some log values, however, such as total transfer time and message size, can delay generation of the log content, particularly for a large file transfer or remote terminal session.

To avoid such delays, you can choose to log available values as quickly as possible by specifying the logasap option. With this option, the log message is created as soon as the server connection is established in mode tcp or as soon as the server sends the complete headers in mode http.

Values that are not finalized at this time are total time and total size metrics, and they are prefixed with a plus sign "+" in the log to indicate they are not true final values.

In the case of HTTP, it is good practice to capture the Content-Length response header so that the logs at least indicate how many bytes are expected to be transferred.

You can enable early logging by adding option logasap to the defaults, frontend, or listen section, as shown below:

frontend fe_main
   bind 0.0.0.0:80
   mode http
   option httplog
   option logasap
   log global
   http-request capture req.hdr(Content-Length) len 15
>>> Feb  6 12:14:14 localhost \
      hapee-lb[14389]: 10.0.1.2:33317 [06/Feb/2019:12:14:14.655] fe_main \
      static/srv1 9/10/7/14/+30 200 +243 - - ---- 3/1/1/1/0 1/0 \
      "GET /image.iso HTTP/1.0"

Next up

Log Format for Access Logs
HAProxyConf 2022 - Call for papers