Forum Discussion

Rich_Caldwell_7's avatar
Rich_Caldwell_7
Icon for Nimbostratus rankNimbostratus
Oct 12, 2007

Logging after built-in Variable modification

I noticed that after modifying a built in variable such as [HTTP::uri], when you try to log the change, it does not log the new value. See below in my code, where I change the value of [HTTP::uri], then attempt to log the changed value. It simply prints to my ltm log the original value of [HTTP::uri]. This drove me crazy until I started to monitor via tcpdump and see the real value. The code is functioning, except for the the fact that the log function does not print the changed value of the built-in. Does anyone know why, or how to print the changed value to my log?

 

 

Also, any comments on my use of the findclass to map a URI to a pool. I did not want to use a huge case statement, so I hope this will work by building a Data Class to map the URI to a Pool. My mapping will be up to about 20 different URI-to-Pools, so I thought this would be more efficient than a case or if/else statement.

 

 

when HTTP_REQUEST {

 

log local0. "HTTP::uri original: [HTTP::uri]"

 

set orig_uri [HTTP::uri]

 

set new_uri [findclass [HTTP::uri] $::BMF_URL_Mapping " "]

 

log local0. "Original URI: orig_uri: Maps to: $new_uri"

 

HTTP::uri "$new_uri"

 

=============================================================

 

THIS CODE DOES NOT PRINT THE MODIFIED URI AS ONE WOULD EXPECT

 

=============================================================

 

log local0. "HTTP::uri modified: [HTTP::uri]"

 

set myPool [findclass [HTTP::uri] $::BMF_URL_to_Pool_Map " "]

 

if {$myPool != ""} {

 

pool $myPool

 

log local0. "Sending URL Path: [HTTP::uri] ..to.. Pool: $myPool"

 

} else {

 

log local0. "No Pool found for [HTTP::uri] Please add a mapping to BMF_URL_to_Pool_Map"

 

}

 

}

 

 

class BMF_URL_Mapping {

 

"/ParlayXWeb/services/MobileTerminalLocation /MobileTerminalLocationService/a87ff679a2f3e71d9181a67b7542122c"

 

"/ParlayXWeb/services/MobileTerminalLocation/ /MobileTerminalLocationService/a87ff679a2f3e71d9181a67b7542122c/"

 

"/ParlayXWeb/services/Activate /MobileTerminalLocationService/azz87679a2f3e71d9181a67b7542122c"

 

"/ParlayXWeb/services/Activate/ /MobileTerminalLocationService/azz87679a2f3e71d9181a67b7542122c/"

 

"/ParlayXWeb/services/Term /MobileTerminalLocationService/azz87679a2f3e71d9181a67b75425543"

 

"/ParlayXWeb/services/Term/ /MobileTerminalLocationService/azz87679a2f3e71d9181a67b75425543/"

 

}

 

 

class BMF_URL_to_Pool_Map {

 

"/ParlayXWeb/services/MobileTerminalLocation BMF_New_Loads_9018"

 

"/ParlayXWeb/services/MobileTerminalLocation/ BMF_New_Loads_9018"

 

"/ParlayXWeb/services/MobileTerminalLocation1 BMF_New_Loads_9019"

 

"/ParlayXWeb/services/MobileTerminalLocation1/ BMF_New_Loads_9019"

 

"/ParlayXWeb/services/MobileTerminalLocation2 BMF_New_Loads_9020"

 

"/ParlayXWeb/services/MobileTerminalLocation2/ BMF_New_Loads_9020"

 

}

 

1 Reply

  • As you found, some of the values are cached for performance reasons. I haven't seen a complete list of which are though. Unfortunately, if you want to log the modified version, you'd need to perform the function twice. Here's an example which sets the path to lowercase and logs the change:

    
    when HTTP_REQUEST {
        modify the path, set it to lowercase
       HTTP::path [string tolower [HTTP::path]]
        now log the change
       log local0. "path changed to: [string tolower [HTTP::path]]"
    }

    Aaron