Forum Discussion
Mazen2006_14317
Nimbostratus
Feb 17, 2014iRule to log HTTP request as Apache combined standard format
Hello,
I need to log HTTP request and response as Apache combined standard format like this:
LogFormat "%h %{X-ReqTime}o %D %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined ...
IheartF5_45022
Nacreous
Feb 19, 2014Hi - I am being a bit lazy and have not given you everything you neded but this should get you off to a good start;
when CLIENT_ACCEPTED {
set hsl [HSL::open -proto UDP -pool $syslog_server_pool]
}
when HTTP_REQUEST {
Save request information for later logging
set req_start [clock clicks -milliseconds]
set clientip [IP::client_addr]
set method [HTTP::method]
set uri [HTTP::uri]
set referer [HTTP::header Referer]
set ua [HTTP::header User-Agent]
}
when HTTP_RESPONSE {
set log_string "$clientip [clock format [clock seconds] -format "%d/%m/%Y %H:%M:%S %z"] [expr {[clock clicks -milliseconds] - $req_start}] \"$method $uri\" [HTTP::status] [HTTP::header Content-Length] \"$referer\" \"$ua\""
log local0. $log_string
HSL::send $hsl $log_string
}
Have commented out the HSL (to log to an external device) commands, and we are just logging to /var/log/ltm.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
