How to log locally Using F5 iRule for quick troubleshooting

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.

All in One WordPress Hosting Starts at 30$ per month
All in One WordPress Hosting
WordPress
High optimized WordPress hosting, secure firewall, HTTPS, Backup, hack-fix guarantee and many others at 30$ per month

Ref: