• 2 min read

Client Side Tracing for Windows Azure AppFabric Caching

In this post, I will describe how to enable Client-side traces for AppFabric Caching Service. I will also touch upon some basic problems you might face while trying out the same. To configure the…

In this post, I will describe how to enable Client-side traces for AppFabric Caching Service. I will also touch upon some basic problems you might face while trying out the same.

To configure the cache client to generate System.Diagnostic.Traces pertaining to the AppFabric cache, please follow the below steps:

Configuration File Option

In your app.config/web.config you need to add , to the appropriate location as per the cases below:

a.     DataCacheClients Section

If you have a ‘dataCacheClients’ section in your app.config/web.config file under section, then add the tracing section as below:

 

   

 

 

   

   

   

     

       

     

     

       

       

     

   

 

  …

Note: Tracing section should be a direct child of the section and should not be added under section(s), if section is present.

b.     DataCacheClient Section

If you do not have a section, and the app.config/web.config has only a section, then add the Tracing section as below:

 

   

 

 

                 

        

           

           

        

        

           

 

    …

Programmatic Option

You may also choose to set the System.Diagnostic.Trace for cache client programmatically, by calling the below method at any point:

//Argument 1 specifies that a System.Diagnostic.Trace will be used, and

//Argument 2 specifies the trace level filter.

DataCacheClientLogManager.SetSink(DataCacheTraceSink.DiagnosticSink, System.Diagnostics.TraceLevel.Verbose);

You may also change the level at which the trace logs are filtered, programmatically by calling the below method at any stage (say, 5 minutes after your service has started and stabilized you may want to set the cache client trace level to Warning instead of Verbose):

DataCacheClientLogManager.ChangeLogLevel(System.Diagnostics.TraceLevel.Warning);

Troubleshooting

If you are using Azure SDK 1.3 or above, and trying to get cache client side traces within a Web Role using the above mechanism on DevelopmentFabric environment, you will not be able to see the Cache client traces on the Development Fabric Emulator (or DevFabric UI)

–       Reasoning/Explanation for the given behavior

With SDK 1.3, the IIS (Role Runtime) runs in a separate process as compared to web role (for ASP.Net session state provider scenario) and all the logs related to Web Role can be seen in the DevFabric UI, however, the cache client side traces go as part of IIS i.e. the Role Runtime. The DevFabric Emulator attaches its own listener “DevelopmentFabricTraceListener” by default and its UI emits logs only heard by this listener. Since IIS is in a different process, this listener is not present and logs cannot be seen on the DevFabric UI.

–       Resolution

Note: The resolution below is only to see logs for DevFabric scenario; otherwise the logs would go to xStore (Azure Storage Account) in a perfectly fine manner. For your project, add the below in web.config under section:


  

–       You may add this only for your Web.Debug.config, so that when you actually deploy to an Azure environment, this section does not get added as you will use Web.Release.config file.

–       You also need *not* add a reference to the DLL “Microsoft.ServiceHosting.Tools.DevelopmentFabric.Runtime.dll” as the machine on which you are deploying it on Development Fabric should have this DLL present in GAC (Search for this DLL under %windir%assembly).

–       Deploy the sample on DevFabric, and you should now be able to see the Cache traces on the Development Fabric UI.

For any questions or feedback regarding the Caching service please visit the Windows Azure Storage, CDN and Caching forum.

Sharad Agrawal – On behalf of the AppFabric Team

Tweet