Forum Discussion
Robert_Sutcliff
Nimbostratus
Jun 05, 2008logging and redirects
Hi,
We're having problems setting up logging (similar to apache http access logs). We need to log all the relevant data onto one line, so that we don't get data from lots of concurrent requests...
hoolio
Cirrostratus
Jun 05, 2008I don't think there is a way to determine that HTTP::redirect or HTTP::respond have been used to respond to an HTTP request. You could set a variable in the redirect rule(s) and then look for that in the logging rule. You could use priority to dictate that the HTTP_REQUEST event in the log rule runs after the default priority of 500 (when HTTP_REQUEST priority 501). You could then log the request/response details in HTTP_REQUEST if the request is being redirected by another rule. You'd also want to make sure to unset the variable (or set the value to 0) if the request isn't being responded to from the rule, so the variable will be valid for all HTTP requests on the same TCP connection.
Also, someone mentioned previously that it's more efficient to save the log items in a single variable compared with using half a dozen:
when HTTP_REQUEST priority 501 {
Check if another rule on this request has issued a response
if {[info exists redirected] && $redirected]}{
Log the request details now, as there won't be a server response
log local0. "[virtual] [HTTP::host] [IP::client_addr] - \[[clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S %z}]\] \"[HTTP::method] [HTTP::uri]\" - -"
} else }{
Request isn't being answered from the BIG-IP so save the request details for logging in HTTP_RESPONSE
set request_info "[virtual] [HTTP::host] [IP::client_addr] - \[[clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S %z}]\] \"[HTTP::method] [HTTP::uri]\" ..."
}
}
when HTTP_RESPONSE {
Response received from the pool. Log the request + response details
log local0. "$request_info + some response details"
}
when LB_FAILED {
Load balancing the request failed, so log the request details here?
log local0. "$request_info - something indicating no server response?"
}
Here is an example rule which could redirect the client and set a variable to track the redirection.
when HTTP_REQUEST {
Check if some condition is true
if {$some_condition == 1}{
Track that the client is being redirected
set redirected 1
Redirect the client
HTTP::redirect https://example.com
} else {
Track that the client is not being redirected
set redirected 0
}
}
Aaron
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
