Forum Discussion
iRule to Log all the HTTP Requests.
Hi,
-
Can we log each HTTP request (GET / POST) coming to a VS i.e. when a client connects to a virtual server on port 80 then can we add a log entry for every HTTP request from that connection or session.
-
The Below iRule logs the IP of the client, Does this iRule get triggered for every HTTP Request ( GET / POST) with in a single connection so that there will be multiple entries of same client ip for a single connection.
when HTTP_REQUEST {
set VS [IP::local_addr]
set URI [HTTP::uri]
log "Client [IP::client_addr]:[TCP::client_port] connected to VS ($vip)for URI $URI"
}
Thanks,
Yugandhar.
- Andy_McGrath
Cumulonimbus
You should to log to a facility and a log level using
( see iRule wiki log reference) also your reference for the Virtual Server address is wrong and pointing to an invalid variable namelog local0.
where you set$vip
.$VS
This should work for you:
when HTTP_REQUEST { set vip [IP::local_addr] set uri [HTTP::uri] log local0.info "Client [IP::client_addr]:[TCP::client_port] connected to VS ($vip)for URI $uri" }
- youssef1
Cumulonimbus
Hi,
You can use this:
when HTTP_REQUEST { log local0. "LOGS: VS Name: [virtual]" log local0. "LOGS: Request: [HTTP::method] [HTTP::host][HTTP::uri]" foreach aHeader [HTTP::header names] { log local0. "LOGS: $aHeader: [HTTP::header value $aHeader]" } }
You will retrieve Virtual Name, Method, Request and all request header.
Regards,
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com