2012-11-23 88 views
7

工作我試圖讓跟蹤日誌在Windows Azure中我的輔助角色,但它不工作,看不出任何錯誤。Azure診斷不是在我的輔助角色

我已經配置了我的應用程序,在這裏講解了使用Azure診斷:https://www.windowsazure.com/en-us/develop/net/common-tasks/diagnostics/

首先,我在我的工人角色的app.config有這樣的:

<system.diagnostics> 
    <trace> 
     <listeners> 
      <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       name="AzureDiagnostics"> 
       <filter type="" /> 
      </add> 
     </listeners> 
    </trace> 
</system.diagnostics> 

然後,在我的ServiceConfiguration .Cloud.cscfg我有這樣的連接字符串:

<ConfigurationSettings> 
    <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=XXXXXXX;AccountKey=XXXXXXXXX" /> 
    ... 

在我ServiceDefinition.csdef中我有:

<Import moduleName="Diagnostics" /> 

終於在我有WorkerRole.cs的的OnStart()方法:

var config = DiagnosticMonitor.GetDefaultInitialConfiguration(); 
     config.Logs.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(1.0); 
     config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Information; 

     DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config); 

然後,我做我的run()方法中的一些Trace.WriteLine()。

這應該在存儲中創建WADLogsTable,但事實並非如此。

當我通過遠程桌面連接到我的情況,我沒有看到在事件查看器中的任何錯誤,我看到的唯一奇怪的是在那裏我看到了DiagnosticsAgent.exe過程中啓動了兩次WaHostBootstrapper日誌,然後當獲得狀態時,一個過程響應,另一個不響應,這是日誌的一部分:

[00002868:00002872, 2012/11/23, 21:26:30.367, 00100000] <- WapGetEnvironmentVariable=0x800700cb 
[00002868:00002872, 2012/11/23, 21:26:30.383, 00100000] <- WapGetEnvironmentVariable=0x800700cb 
[00002868:00002872, 2012/11/23, 21:26:30.414, 00040000] Executing Startup Task type=2 rolemodule=Diagnostics cmd="E:\plugins\Diagnostics\DiagnosticsAgent.exe" 
[00002868:00002872, 2012/11/23, 21:26:30.414, 00040000] Executing "E:\plugins\Diagnostics\DiagnosticsAgent.exe" . 
[00002868:00002872, 2012/11/23, 21:26:30.414, 00100000] <- WapGetEnvironmentVariable=0x800700cb 
[00002868:00002872, 2012/11/23, 21:26:30.446, 00100000] <- WapGetEnvironmentVariable=0x800700cb 
[00002868:00002872, 2012/11/23, 21:26:30.477, 00040000] Executing Startup Task type=0 rolemodule=Diagnostics cmd="E:\plugins\Diagnostics\DiagnosticsAgent.exe" /blockStartup 
[00002868:00002872, 2012/11/23, 21:26:30.477, 00040000] Executing "E:\plugins\Diagnostics\DiagnosticsAgent.exe" /blockStartup. 
[00002868:00002984, 2012/11/23, 21:26:30.821, 00040000] Registering client with PID 2964. 
[00002868:00002984, 2012/11/23, 21:26:30.821, 00040000] Client DiagnosticsAgent.exe (2964) registered. 
[00002868:00002984, 2012/11/23, 21:26:30.821, 00040000] Registering client with PID 2940. 
[00002868:00002984, 2012/11/23, 21:26:30.821, 00040000] Client DiagnosticsAgent.exe (2940) registered. 
[00002868:00002872, 2012/11/23, 21:26:45.961, 00040000] Program "E:\plugins\Diagnostics\DiagnosticsAgent.exe" /blockStartup exited with 0. Working Directory = E:\plugins\Diagnostics 
[00002868:00002872, 2012/11/23, 21:26:45.961, 00100000] <- WapGetEnvironmentVariable=0x800700cb 
[00002868:00002872, 2012/11/23, 21:26:45.992, 00100000] <- WapGetEnvironmentVariable=0x800700cb 
[00002868:00002872, 2012/11/23, 21:26:46.008, 00040000] Executing Startup Task type=2 rolemodule=RemoteAccess cmd="E:\plugins\RemoteAccess\RemoteAccessAgent.exe" 
[00002868:00002872, 2012/11/23, 21:26:46.008, 00040000] Executing "E:\plugins\RemoteAccess\RemoteAccessAgent.exe" . 
[00002868:00002872, 2012/11/23, 21:26:46.008, 00100000] <- WapGetEnvironmentVariable=0x800700cb 
[00002868:00002872, 2012/11/23, 21:26:46.055, 00100000] <- WapGetEnvironmentVariable=0x800700cb 
[00002868:00002872, 2012/11/23, 21:26:46.071, 00040000] Executing Startup Task type=0 rolemodule=RemoteAccess cmd="E:\plugins\RemoteAccess\RemoteAccessAgent.exe" /blockStartup 
[00002868:00002872, 2012/11/23, 21:26:46.117, 00040000] Executing "E:\plugins\RemoteAccess\RemoteAccessAgent.exe" /blockStartup. 
[00002868:00002984, 2012/11/23, 21:26:46.399, 00040000] Registering client with PID 936. 
[00002868:00002984, 2012/11/23, 21:26:46.399, 00040000] Client RemoteAccessAgent.exe (936) registered. 
[00002868:00002936, 2012/11/23, 21:26:46.430, 00040000] Registering client with PID 2432. 
[00002868:00002936, 2012/11/23, 21:26:46.430, 00040000] Client RemoteAccessAgent.exe (2432) registered. 
[00002868:00002872, 2012/11/23, 21:26:47.586, 00040000] Program "E:\plugins\RemoteAccess\RemoteAccessAgent.exe" /blockStartup exited with 0. Working Directory = E:\plugins\RemoteAccess 
[00002868:00002872, 2012/11/23, 21:26:47.586, 00100000] <- GetDebugger=0x1 
[00002868:00002872, 2012/11/23, 21:26:47.602, 00100000] <- GetRoleHostDebugger=0x1 
[00002868:00002872, 2012/11/23, 21:26:47.633, 00100000] <- WapXmlReadContainerId=0x1 
[00002868:00002872, 2012/11/23, 21:26:47.649, 00100000] <- WapGetVirtualAccountName=0x1 
[00002868:00002872, 2012/11/23, 21:26:47.664, 00040000] Executing base\x64\WaWorkerHost.exe . 
[00002868:00002872, 2012/11/23, 21:26:47.664, 00040000] Role host process PID: 2560. 
[00002868:00002936, 2012/11/23, 21:26:47.742, 00040000] Registering client with PID 2560. 
[00002868:00002936, 2012/11/23, 21:26:47.742, 00040000] Client WaWorkerHost.exe (2560) registered. 
[00002868:00002936, 2012/11/23, 21:26:47.742, 00040000] Client process 2560 is the role host. 
[00002868:00002936, 2012/11/23, 21:26:47.742, 00040000] Role host process registered. 
[00002868:00002892, 2012/11/23, 21:26:47.899, 00040000] Getting status from client DiagnosticsAgent.exe (2964). 
[00002868:00002892, 2012/11/23, 21:26:47.899, 00100000] Failed to connect to client DiagnosticsAgent.exe (2964). 
[00002868:00002892, 2012/11/23, 21:26:47.914, 00100000] <- CRuntimeClient::OnRoleStatusCallback(0x00000000007EE660) =0x800706ba 
[00002868:00002892, 2012/11/23, 21:26:47.961, 00040000] Getting status from client DiagnosticsAgent.exe (2940). 
[00002868:00002892, 2012/11/23, 21:26:47.961, 00040000] Client reported status 0. 

有什麼不對嗎?如何將這些診斷信息發佈到我的天藍色存儲?

+0

它看起來對我好,你試過先運行它針對本地devstore – Guy

+0

是的,它工作在本地 – Escobar5

回答

11

編輯爲我最初誤解,你正在運行一個webrole - 哎呀。

隨着輔助角色,嘗試刪除它描述了記錄設置的斑點,然後重新部署。您將在您用於診斷的存儲帳戶的wad-control-container blob目錄下找到blob。

下面是我原來的答覆,但它僅適用,如果你正在運行一個webrole。我將它留在這裏,因爲這是一個明顯的陷阱,所以也許這爲某人節省了一些時間:

這可能是因爲您的webrole.cs代碼在Web應用程序的單獨AppDomain中運行(如果您在完整的IIS)。即使在web.config中配置了Azure DiagnosticMonitorTraceListener,它對運行webrole.cs代碼的AppDomain也沒有影響。因此,Azure診斷跟蹤偵聽器未在Run方法中註冊,並且跟蹤無處可用。

我要做兩件事情:。 - 添加Azure診斷跟蹤偵聽明確代碼中的OnStart(Trace.Listeners.Add(新DiagnosticMonitorTraceListener()) - 從Web應用程序寫一些日誌,這有可能將。觸發WADLogsTable創建

+0

刪除BLOB做到了感謝 – Escobar5

+0

+1對於原來的答案;?我有一個webrole.cs作爲「worker角色」運行,跟蹤不起作用。按照您所描述的方式添加Trace Listener修復了我的問題 –

+0

+1 Thanks。就我而言,我相信自己也有同樣的問題。但是,我只是沒有意識到,Azure診斷程序將它們上傳到表WADLogsTable,我正在尋找斑點並沒有找到任何東西 –