Customizing the Log Format

Log format variables

A log format variable is a string prefixed by the character %:

%variable

If a variable is between square brackets ([ .. ]), then it is used as a sample fetch expression rule: (More about data fetches)

%[req.hdr(Host)]

Variables can take arguments using braces ({ .. }). You can pass multiple arguments separated by commas and within the braces. You can prefix each argument with a flag in order to add or remove it with a + or - character:

%{+Q}[req.hdr(Host)]

You can use a special variable %o to propagate its flags to all following variables in the same format string:

Warning

Avoid spaces; a space character is considered as a separator.

Note

To emit a verbatim %, it must be preceded by another % to result in %%. HAProxy automatically merges consecutive separators.

Available flags are : * Q: quote a string * X: hexadecimal representation (IPs, Ports, %Ts, %rt, %pid)

The following table lists available variables:

Variable

Field Name

Type

Limitations

%o

Special variable, apply flags to all next variables

%B

bytes_read (from server to client)

Numeric

%CC

captured_request_cookie

String

mode http only

%CS

captured_response_cookie

String

mode http only

%H

hostname

String

%HM

HTTP method (ex: POST)

String mode

HTTP only

%HP

HTTP request URI without query string (path)

String

mode http only

%HQ

HTTP request query string (ex: ?foo=bar )

String

mode http only

%HU

HTTP request URI including the query string

String

mode http only

%HV

HTTP version (ex: HTTP/1.0)

String

mode http only

%ID

unique-id

String

%lc

frontend_log_counter

Numeric

%ST

status_code

Numeric

%T

gmt_date_time

Date

%Tc

Tc

Numeric

%Tl

local_date_time

Date

%Tq

Tq

Numeric

mode http only

%Tr

Tr

Numeric

mode http only

%Ts

timestamp

Numeric

%Tt

Tt

Numeric

%Tw

Tw

Numeric

%U

bytes_uploaded (from client to server)

Numeric

%ac

actconn

Numeric

%b

backend_name

String

%bc

beconn (backend concurrent connections)

Numeric

%bi

backend_source_ip (connecting address)

IP

%bp

backend_source_port (connecting address)

Numeric

%bq

backend_queue

Numeric

%ci

client_ip (accepted address)

IP

%cp

client_port (accepted address)

Numeric

%f

frontend_name

String

%fc

feconn (frontend concurrent connections)

Numeric

%fi

frontend_ip (accepting address)

IP

%fp

frontend_port (accepting address)

Numeric

%ft

frontend_name_transport ('~' suffix for SSL)

String

%hr

captured_request_headers default style

String

%hrl

captured_request_headers CLF style

String list

%hs

captured_response_headers default style

String

%hsl

captured_response_headers CLF style

String list

%ms

accept date milliseconds

Numeric

%pid

PID

Numeric

%r

http_request

String

mode http only

%rc

retries

Numeric

%rt

request_counter (HTTP req or TCP session)

Numeric

%s

server_name

String

%sc

srv_conn (server concurrent connections)

Numeric

%si

server_IP (target address)

IP

%sp

server_port (target address)

Numeric

%sq

srv_queue

Numeric

%sslc

ssl_ciphers (ex: AES-SHA)

String

SSL only

%sslv

ssl_version (ex: TLSv1)

String

SSL only

%t

date_time (with millisecond resolution)

Date

%ts

termination_state

String

%tsc

termination_state with cookie status

String

mode http only