2016-07-01 2 views
1

Semantic Logging Application Block을 사용하여 로그를 Azure Table Storage에 저장하려고합니다. 설정 :리스너에 Azure 싱크를 설정하려고 할 때 예외 소스를 추적하는 방법

ObservableEventListener listener1 = new ObservableEventListener(); 
var conString = 
    $"DefaultEndpointsProtocol={CloudStorageAccount.DevelopmentStorageAccount.TableEndpoint.Scheme};" + 
    $"AccountName={CloudStorageAccount.DevelopmentStorageAccount.Credentials.AccountName};" + 
    $"AccountKey={Convert.ToBase64String(CloudStorageAccount.DevelopmentStorageAccount.Credentials.ExportKey())}"; 

listener1.LogToWindowsAzureTable(// <---- EXCEPTION HERE 
     instanceName: "instName", 
     connectionString: conString); 

내가 이상한 예외를 받고 있어요 : 던져

예외 : 'System.MissingMethodException'을 Microsoft.Practices.EnterpriseLibrary.SemanticLogging.WindowsAzure.dll에

추가 정보 : 메서드를 찾을 수 없음 : 'Void Microsoft.WindowsAzure.Storage.Table.CloudTableClient.set_RetryPolicy (Microsoft.WindowsAzure.Storage.RetryPolicies.IRetryPolicy)'.

실제 계정에 동일한 문제가 있습니다. 패키지 버전 (그들 모두는 NuGet 출신) :

  • EnterpriseLibrary.SemanticLogging - 2.0.1406.1
  • EnterpriseLibrary.SemanticLogging.WindowsAzure - 2.0.1406.1
  • WindowsAzure.Storage - 7.0.0

예외 소스를 어떻게 추적 할 수 있습니까? Google은 발견되지 않은 방법에 대해 아무 말도하지 않습니다. 컴퓨터에서 테스트 할 프로젝트는 here입니다.

+0

참고하지만, (응용 프로그램 통찰력에 AI를에 업로드)가 더 좋습니다 : https://github.com/fidmor89/SLAB_AppInsights. 표준 또는 프리미엄 계층이있는 경우 테이블 저장소에 대한 지속적인 내보내기를 구성하고이를 무료로 가져올 수 있습니다. –

답변

3

SLAB 버전 4.0.0.0 (source를)에서 사용되지 않으며에서 제거 스토리지 클라이언트 라이브러리 3.0.2.0 (source)와 클라이언트에 Retry Policies (예를 들어 CloudTableClient)를 설정에 의존하기 때문에이 오류를 얻고있는 이유는 어떤 최신 버전 (어느 것이 확실하지 않음).

저장소 클라이언트 라이브러리 버전 7.x를 사용 중이므로 CloudTableClient에 RetryPolicy를 설정하는 방법이 없으므로이 오류가 발생합니다.

+0

7.0.0에서는 더 이상 사용되지 않습니다 (아직 6.2.2 미리 있음) –

1

Guarav와 마찬가지로 SLAB은 Microsoft.WindowsAzure.Storage의 아주 오래된 버전에 맞춰 제작되었습니다. 문제는 this line이며 client.DefaultRequestOptions.RetryPolicy 대신 client.RetryPolicy을 사용합니다. NuGet 패키지를 업데이트하고 변경하려고 시도했지만 일부 테스트가 중단 된 것처럼 보였으 나이를 수정하는 것이 간단하지 않았습니다. 또한 그것은 4.6 지원처럼 보이지 않습니다 : https://github.com/mspnp/semantic-logging/issues/64.

여기에 결함이 있습니다. https://github.com/mspnp/semantic-logging/issues/81,하지만 의심스러운 것이 있습니다. 아무 때 나 곧 그럴 수 있습니다. 아마도 Azure가 처리 할 로그 (예 : Table Storage upload)를 추적 수신기로 리디렉션하는 간단한 싱크를 작성하게 될 것입니다.

public class SystemDiagnosticsTraceSink : IObserver<EventEntry> 
{ 
    public void OnNext(EventEntry entry) 
    { 
     if (entry == null) return; 
     using (var writer = new StringWriter()) 
     { 
      new EventTextFormatter().WriteEvent(entry, writer); 
      var eventText = writer.ToString(); 
      switch (entry.Schema.Level) 
      { 
       case EventLevel.LogAlways: 
       case EventLevel.Critical: 
       case EventLevel.Error: 
        Trace.TraceError(eventText); 
        return; 
       case EventLevel.Warning: 
        Trace.TraceWarning(eventText); 
        return; 
       case EventLevel.Informational: 
       case EventLevel.Verbose: 
        Trace.TraceInformation(eventText); 
        return; 
       default: 
        Trace.TraceError("Unknown event level: " + entry.Schema.Level); 
        Trace.TraceInformation(eventText); 
        return; 
      } 
     } 
    } 
    public void OnError(Exception error) 
    {} //you might want to do something here 
    public void OnCompleted() 
    {} //nothing to do 
} 

그리고 확장 클래스 :

EDIT 여기에 코드 (아직 테스트하지)의 푸른 테이블에 로그를 업로드하는 것은 좋은 것을

public static class SystemDiagnosticsTraceSinkExtensions 
{ 
    public static SinkSubscription<SystemDiagnosticsTraceSink> LogToSystemDiagnosticsTrace 
     (this IObservable<EventEntry> eventStream) 
    { 
     if (eventStream == null) throw new ArgumentNullException(nameof(eventStream)); 

     var sink = new SystemDiagnosticsTraceSink(); 
     return new SinkSubscription<SystemDiagnosticsTraceSink>(
         eventStream.Subscribe(sink), sink); 
    } 
}