2013-05-08 4 views
3

캐시 역할을 사용하여 데이터를 공유하는 두 가지 역할이 있습니다. 우리가 배포 할 때 우리는 로그에 다음 항목 중 많은 많은을 얻을 :WAD 로그에서 하늘색 캐시 클라이언트 경고를 표시하지 않는 방법

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 

이 설정 값을 변경 :

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

효과가 없습니다 것으로 보인다.

WADLogs 테이블에서이 노이즈를 제거하는 방법에 대한 아이디어가 있으십니까?

답변

4

캐싱에 버그가있는 것 같습니다 (이 post 참조). 나는 SDK1.8을 실행하는 행운이 로그 항목을 없애려고 했어. 최근에 SDK2.0으로 전환했지만 불행히도 문제는 아직 해결되지 않았습니다.

Bug report on GitHub

1

나는 이것에 대한 필터를 추가 할거야. 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> 

참고 : 속성 initializeDataSystem.Diagnostics.SourceLevels 열거의 텍스트로 설정됩니다. 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: <[^>*]*>"); 
    } 
} 

당신은/포함 무시하고 다른 패턴을 받아들이 구성을 실행할 수있는보다 일반적인 필터에이를 확장 할 수 있습니다.

+0

Phil이 작품을 작성 하셨나요? 최신 SDK (v2.2)에서 'ClientDiagnosticLevel'을 적용하지 않고 동일한 문제가 발생합니다.이 솔루션은 이상적으로 해결됩니다. –

+0

@ Click-Rex 개념은 건전하고 현지에서 테스트 할 때 필터가 맞았습니다. 적절한 해결 방법이지만 푸른 진단, 특히 구성을 올바르게 읽도록 구성하는 방법에 대해 더 자세히 읽으 려하고 있습니다. –

1

this thread on GitHub의 끝에 제안을 읽고 나면 우리는 응용 프로그램에서 다음 코드를 실행하여이를 사용하지 않도록 관리 : 당신이 해제하지 않고

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

이 모든 푸른 캐시 클라이언트에서 로그인을 중지하여 자신의 Warning 또는 Information 레벨 로그 여기

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

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

     InitializeCache(); 
    } 
1

그냥 네임 스페이스 및 해당 어셈블리 이름을 사용해야합니다 완벽한 솔루션을 수 있습니다 :

우리는 DataCacheClient 주위에 우리 캐시 제공자 래퍼의 생성자이 추가 끝났다.

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); 
     } 
    } 
} 

희망이 있습니다.