我正在尝试为我在 Windows 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,但事实并非如此。
当我通过远程桌面连接到我的实例时,我在事件查看器中看不到任何错误,我看到的唯一奇怪的事情是 WaHostBootstrapper 日志,我看到 DiagnosticsAgent.exe 进程启动了两次,然后在获得状态一时进程响应而另一个没有,这是日志的一部分:
[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.
有什么不对的吗?如何将这些诊断信息发布到我的 Azure 存储?