There are times that as an F5 administrator, you wanted to log traffic to debug and troubleshoot an request or response that is processed by F5 appliance.
Here is handy iRule script that logs following
– Client IP address & port
– Requested URL
– Virtual Server Name specified in F5
– Pool Name
– Node Selected in the Pool
– Response Code
—- code starts
when HTTP_REQUEST {
set client [IP::client_addr]:[TCP::client_port]
set url [HTTP::header Host][HTTP::uri]
…your piece of code…
}
when HTTP_RESPONSE
{
set node [IP::server_addr]:[TCP::server_port]
set nodeResp [HTTP::status]
# log connection info
log local0.info “Client: $client request URL is $url and accessed Virtual Server Name [virtual]. Selected pool server is [LB::server]. Node $node responded with $nodeResp”
}
—- code ends
local0.info logs to default log file location /var/log/ltm.
Ref:
- Click to view F5 article on available logging facility.
- Click to view lists of all available parameters from which you can create a custom HTTP Request Logging profile.
- Does Logging affect performance?