我有一個現有的WCF Web服務,其中一個.cs文件中包含三個WebGet處理程序。這些處理程序會對其他.cs文件進行適當的調用以處理該操作。使用WebGet Web服務進行Azure日誌記錄
現在,我通過創建Azure項目並添加現有解決方案,基於此Web服務創建了一個Azure項目。現在,我想使用Trace.WriteLine進行日誌記錄。我設置了.cscfg,.csdef和Web.config文件以允許記錄到Azure存儲。
不過,我不知道在哪裏設置以下信息:
//Get the default configuration
DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();
//Set the schedule to transfer logs every 10 mins to the storage
dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(10);
//Start Diagnostics Monitor with the storage account configuration
DiagnosticMonitor.Start("DiagnosticsConnectionString",dmc);
我試圖將其放置在一個包含記錄方法的獨立的內部靜態類,但我得到一個RoleEnvironmentException:錯誤時我運行網絡服務。
因爲我的Web服務類中沒有帶三個WebGets的OnStart()方法,在哪裏可以確保我的診斷監視器正確啓動,以便可以使用Trace.WriteLine?