2016-03-04 61 views
0

我正在使用Microsoft EventSource Library來實現我的Web應用程序的日誌記錄機制。爲什麼通道「調試」和「分析」不適用於我的ETW-EventSource實施?

該庫提供四個日誌事件通道:「Admin」,「Operational」,「Debug」和「Analytic」。管理員和操作頻道工作正常,頻道可見,我可以記錄事件。

出於某種原因,調試和分析通道不會出現在事件查看器,你可以在這個截圖中看到:

enter image description here

下面你可以看到我的EventSource實現。此外,我已經上傳了完整的Visual Studio項目,包括一個控制檯測試應用程序here

有誰知道爲什麼只有Admin和Operational可用?

public static partial class WebAppEventSourceHandler 
{ 
    [EventSource(Name = "Company-MyProject-WebApp")] 
    private sealed class WebAppEventSource : EventSource 
    { 
     [Event(1, Message = "Instance: [{0}] Exception Type: [{1}] Exception Message: [{2}] Exception Stack Trace: [{3}] Inner Exception Type: [{4}] Inner Exception Message: [{5}] Inner Exception Stack Trace: [{6}]", 
      Channel = EventChannel.Admin, Level = EventLevel.Critical, Version = 1)] 
     internal void UnhandledException(string instance, string exceptionType, string exceptionMessage, string exceptionStackTrace, 
      string innerExceptionType, string innerExceptionMessage, string innerExceptionStackTrace) 
     { 
      WriteEvent(1, instance, exceptionType, exceptionMessage, exceptionStackTrace, innerExceptionMessage, 
       innerExceptionType, innerExceptionMessage, innerExceptionStackTrace); 
     } 

     [Event(2, Message = "Instance: [{0}] Controller: [{1}] Action: [{2}] Client Message: [{3}] Server Message: [{4}] Parameter: [{5}]", 
      Channel = EventChannel.Admin, Level = EventLevel.Error, Version = 1)] 
     internal void LogControllerActionError(string instance, string controller, string action, 
      string clientSideMessage, string serverSideMessage, string parameter) 
     { 
      WriteEvent(2, instance, controller, action, clientSideMessage, serverSideMessage, parameter); 
     } 

     [Event(3, Message = "Instance: [{0}] Controller: [{1}] Action: [{2}] Client Message: [{3}] Server Message: [{4}] Parameter: [{5}]", 
      Channel = EventChannel.Operational, Level = EventLevel.Warning, Version = 1)] 
     internal void LogControllerActionWarning(string instance, string controller, string action, 
      string clientSideMessage, string serverSideMessage, string parameter) 
     { 
      WriteEvent(3, instance, controller, action, clientSideMessage, serverSideMessage, parameter); 
     } 

     [Event(4, Message = "Instance: [{0}] Controller: [{1}] Action: [{2}] Message: [{3}] Server Parameter: [{4}]", 
      Channel = EventChannel.Operational, Level = EventLevel.Informational, Version = 1)] 
     internal void LogControllerActionInfo(string instance, string controller, string action, 
      string message, string parameter) 
     { 
      WriteEvent(4, instance, controller, action, message, parameter); 
     } 

     [Event(5, Message = "Instance: [{0}] Controller: [{1}] Action: [{2}] Message: [{3}] Server Parameter: [{4}]", 
      Channel = EventChannel.Debug, Level = EventLevel.Verbose, Version = 1)] 
     internal void LogControllerActionDebug(string instance, string controller, string action, 
      string message, string parameter) 
     { 
      WriteEvent(5, instance, controller, action, message, parameter); 
     } 

     [Event(6, Message = "Instance: [{0}] Controller: [{1}] Action: [{2}] Message: [{3}] Server Parameter: [{4}]", 
      Channel = EventChannel.Analytic, Level = EventLevel.Verbose, Version = 1)] 
     internal void LogControllerActionAnalytic(string instance, string controller, string action, 
      string message, string parameter) 
     { 
      WriteEvent(6, instance, controller, action, message, parameter); 
     } 
    } 
} 

我用這個CMD片斷以註冊的EventSource:

C:\ CustomEventSources> wevtutil.exe IM EventSourceExample.Company-MyProject-WebApp.etwManifest.man/RF:「C:\ CustomEventSources \ EventSourceExample.Company-MyProject的-WebApp.etwManifest.dll 「/mf:"C:\CustomEventSources\EventSourceExample.Company-MyProject-WebApp.etwManifest.dll」

+1

你有沒有激活,以顯示分析日誌,在事件查看器的選項的? – magicandre1981

+0

謝謝。而已。我不知道我必須明確地激活它。 –

+0

好的,我發佈它作爲答案。 – magicandre1981

回答

2

通過default the Analytic and Debug are disabled

分析和調試日誌默認是禁用的。啓用後,他們可以快速填充大量的條目。因此,您 可能需要將其打開指定的時間段,以收集 某些故障排除數據,然後再次關閉它們。您可以通過使用Windows界面或 命令行執行此過程,以便 執行此過程。

你必須manually show them in the Eventviewer options

  1. 啓動事件查看器。
  2. 點擊View菜單。如果選擇Show Analytic and Debug Logs,分析和調試日誌已經可見。不需要採取進一步的行動 。如果未選擇Show Analytic and Debug Logs,請選擇Show Analytic and Debug Logs以使這些日誌可見。

enter image description here

相關問題