Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Adding logging to Redirect Irule.

I have an Irule that I wrote to perform redirect when pool becomes unavailable. I am trying to insert some logging because when we are seeing users still accessing old URL when site is unavailable. I have been reading DEV Article about logging but can't seem to make it work. I would like to log client IP and if the redirect is used. Any suggestions would be helpful. Thanks

Here is my Irule when HTTP_REQUEST { if { [HTTP::host] equals "web1.com" }{ if { [active_members web_pool] equals 0 } { HTTP::redirect "http://web2.com" } } }

1
Rate this Question
Comments on this Question
Comment made 08-Sep-2016 by The Y 210

I believe this will help

HTTP_REQUEST { if { [HTTP::host] equals "web1.com" }{ if { [active_members web_pool] equals 0 } { HTTP::redirect "http://web2.com"

log local0. "Client IP Address [IP::client_addr] has been redirected"
} 

} }

0

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Use "log local0." statement wherever you want to log and whatever element you are trying to log:

when HTTP_REQUEST { 
if { [HTTP::host] equals "web1.com" } { 
if { [active_members web_pool] equals 0 } { 
log local0."Host header - [HTTP::host]"
HTTP::redirect "http://web2.com" 
} 
} 
}

Refer to this link for more details.

1
Comments on this Answer
Comment made 08-Sep-2016 by dk 01 58

Thank you both of your suggestions, I have implemented in test and its working great. Still trying to learn the flow and syntax of Irules. Someday I'll get it :)

0