Forum Discussion

dk_01's avatar
dk_01
Icon for Nimbostratus rankNimbostratus
Sep 08, 2016

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" } } }

 

2 Replies

  • 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.

  • I believe this will help

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

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

    } }