3

We have 2 roles which use a cache role to share data. When we deploy we get many many of the following entries in the logs:

INFORMATION: <CASClient> Updated partition table to (1-901) generation: 635036190744461419:0 with transfer (1-901) generation: 635036190744461419:0; TraceSource 'w3wp.exe' event

INFORMATION: <Complaint> Add hard complaint :0 ; TraceSource 'w3wp.exe' event

Changing the values of the setting:

<Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel" value="0" />

seems to have no effect.

Any ideas how we can remove this noise from the WADLogs table?

Sam Holder
  • 32,535
  • 13
  • 101
  • 181

4 Answers4

4

It seems there is a bug in Caching (see this post). I tried to get rid of these log entries with no luck running SDK1.8. Recently I switched to SDK2.0 but unfortunately the problem is still not fixed.

Bug report on GitHub

Pavel Chuchuva
  • 22,633
  • 10
  • 99
  • 115
eXavier
  • 4,821
  • 4
  • 35
  • 57
1

I'm going to be adding a filter for this.

Sample for web.config:

<system.diagnostics>
    <trace>
        <listeners>
            <add name="console" type="System.Diagnostics.ConsoleTraceListener">
                <filter type="Namespace.TraceFilter, Assembly" initializeData="Information"/>
            </add>
        </listeners>
    </trace>
</system.diagnostics>

Note: The attribute initializeData is set to the text from System.Diagnostics.SourceLevels enum. See here.

TraceFilter.cs

public class TraceFilter : EventTypeFilter
{
    public TraceFilter(SourceLevels level)
        : base(level) {}

    public override bool ShouldTrace(TraceEventCache cache, string source, TraceEventType eventType, int id, string formatOrMessage, object[] args, object data1, object[] data)
    {
        return !Regex.IsMatch(formatOrMessage, "INFORMATION: <[^>*]*>");
    }
}

You could extend this to a more generic filter which could run off a configuration accepting different patterns to include/ignore.

Community
  • 1
  • 1
Phil Cooper
  • 3,083
  • 39
  • 63
  • Phil did this work for you? We're getting the same issue on the latest SDK (v2.2) with the `ClientDiagnosticLevel` not being taken into effect and your solution looks ideal as a work around – Luke Merrett Jan 20 '14 at 10:03
  • @Click-Rex the concept was sound and when testing locally, the filter was being hit. It's a suitable workaround but I keep telling myself to read up more on the azure diagnostics, especially the configuration to ensure I'm using them properly. – Phil Cooper Jan 20 '14 at 10:48
1

After reading a suggestion at the end of this thread on GitHub we managed to disable this by running the following code in the application:

DataCacheClientLogManager.ChangeLogLevel(TraceLevel.Off);
DataCacheClientLogManager.SetSink(DataCacheTraceSink.DiagnosticSink, TraceLevel.Off);

This stops all logging from the Azure Cache Client without you having to turn off your own Warning or Information level logs.

We ended up adding this in the constructor of our Cache Provider wrapper around the DataCacheClient:

public class AzureCacheProvider : ICacheProvider
{
    public AzureCacheProvider()
    {
        DataCacheClientLogManager.ChangeLogLevel(TraceLevel.Off);

        DataCacheClientLogManager.SetSink(
            DataCacheTraceSink.DiagnosticSink, 
            TraceLevel.Off);

        InitializeCache();
    }
Luke Merrett
  • 5,724
  • 8
  • 38
  • 70
1

Here is a complete solution

Just make sure to use your namespace and corresponding assembly name.

using Microsoft.WindowsAzure.Diagnostics;
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace MyNamespace
{
    /*
     Solves the Azure In-Role Cache client warnings bug which is too verbose in the WAD logs
     Also Solves Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener not using Filter

     For roles which uses in-role caching, configure your Web.config or app.config with the following system.diagnostics listner and filter:
    <system.diagnostics>
        <trace>
            <listeners>
                <add name="AzureDiagnostics" type="MyNamespace.FilteringDiagnosticMonitorTraceListener, MyAssemblyName">
                <!-- WARNING: does not work with type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                              because the DiagnosticMonitorTraceListener does not call the filter's ShouldTrace method as is was supposed to... -->
                <!-- Note:    working with type="System.Diagnostics.ConsoleTraceListener" -->

                    <filter type="MyNamespace.SuppressCacheClientWarningsTraceFilter, MyAssemblyName" initializeData="Information"/>
                    <!-- Note: The attribute initializeData is set to the text from System.Diagnostics.SourceLevels enum. -->
                </add>
            </listeners>
        </trace>
    </system.diagnostics>
     */

    /// <summary>EventTypeFilter which suppress the 'noise' messages from the In-Role Azure Cache client
    /// </summary>
    /// <remarks>It's a workaround for the following problem http://social.msdn.microsoft.com/Forums/windowsazure/en-US/7ebbc44e-7b61-4bbe-aa54-a85a7788079f/complaint-add-hard-complaint?forum=windowsazuredata.
    /// The solution is based on http://stackoverflow.com/questions/16443856/how-to-suppress-azure-cache-client-warnings-from-the-wad-logs and http://pastebin.com/qKc1aTTW
    /// </remarks>
    public class SuppressCacheClientWarningsTraceFilter : EventTypeFilter
    {

        public SuppressCacheClientWarningsTraceFilter(SourceLevels level)
            : base(level) { }

        public override bool ShouldTrace(TraceEventCache cache, string source, TraceEventType eventType, int id, string formatOrMessage, object[] args, object data1, object[] data)
        {
            return !(
                        (eventType == TraceEventType.Information && Regex.IsMatch(formatOrMessage, @"^INFORMATION:\ <(CASClient|Complaint)>"))
                        || (eventType == TraceEventType.Warning && Regex.IsMatch(formatOrMessage, @"^WARNING:\ <SimpleSendReceiveModule>\ DeadServerCallback"))
                    );
            //return !Regex.IsMatch(formatOrMessage, @"^INFORMATION: <[^>*]*>");
        }
    }

    /// <summary>Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener which uses the configured Trace Filter
    /// </summary>
    /// <remarks>It's a workaround for the following problem http://social.msdn.microsoft.com/Forums/en-US/92ed1175-d6b7-4173-a224-0f7eb3e99481/diagnosticmonitortracelistener-ignors-filter?forum=windowsazuretroubleshooting
    /// The solution is based on the thread comment from "Qin Dian Tang - MSFT": "If you need to use trace filter, then it is needed to use a custom trace listener which derives from DiagnosticMonitorTraceListener, override TraceData, and either manually check filters or call the root class's (TraceListener) TraceData."
    /// </remarks>
    public class FilteringDiagnosticMonitorTraceListener : DiagnosticMonitorTraceListener
    {
        public FilteringDiagnosticMonitorTraceListener() : base() { }

        public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
        {
            if (this.Filter == null || this.Filter.ShouldTrace(eventCache, source, eventType, id, format, args, null, null))
                base.TraceEvent(eventCache, source, eventType, id, format, args);
        }

        public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
        {
            if (this.Filter == null || this.Filter.ShouldTrace(eventCache, source, eventType, id, message, null, null, null))
                base.TraceEvent(eventCache, source, eventType, id, message);
        }
    }
}

Hope it helps.

Michel
  • 11
  • 1