capture response header <name>
len <length>
Capture and log the last occurrence of the specified response header.
May be used in sections :
defaults frontend listen backend no no yes yes yes yes no no Arguments :
<name>
is the name of the header to capture. The header names are not
case-sensitive, but it is a common practice to write them as they
appear in the response, with the first letter of each word in
upper case. The header name will not appear in the logs, only the
value is reported, but the position in the logs is respected.
<length>
is the maximum number of characters to extract from the value and report in the logs. The string will be truncated on the right if it exceeds <length>
.
The complete value of the last occurrence of the header is captured. The result will be added to the logs between braces ('{}') after the captured request headers. If multiple headers are captured, they will be delimited by a vertical bar ('|') and will appear in the same order they were declared in the configuration. Non-existent headers will be logged just as an empty string. Common uses for response header captures include the "Content-length" header which indicates how many bytes are expected to be returned, the "Location" header to track redirections.
There is no limit to the number of captured response headers nor to their length, though it is wise to keep them low to limit memory usage per session.
In order to keep log format consistent for a same frontend, header captures can only be declared in a frontend. It is not possible to specify a capture in a "defaults" section.
Example:
capture response header Content-length len 9
capture response header Location len 15
See also : "capture cookie", "capture request header" as well as section 8 about logging.