我正在尝试在windows azure中获取我的worker角色的跟踪日志,但它不起作用,看不到任何错误。
我已将我的应用程序配置为使用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存储中?
答案 0 :(得分:11)
编辑我最初误读你正在运行webrole - oops。
使用辅助角色,尝试删除描述日志记录设置的blob,然后重新部署。您将在用于诊断的存储帐户中的wad-control-container blob目录下找到blob。
以下是我的原始回复,但只有在您运行webrole时它才适用。我将它留在这里,因为这是一个显而易见的问题,所以也许为某人节省了一些时间:
这可能是因为您的webrole.cs代码在Web应用程序的单独AppDomain中运行(如果您在完整的IIS中托管)。即使在web.config中配置了Azure DiagnosticMonitorTraceListener,它也对运行webrole.cs代码的AppDomain没有影响。因此,Azure诊断跟踪侦听器未在Run方法中注册,并且跟踪无处可去。
我会尝试两件事: - 在OnStart中的代码中显式添加Azure诊断跟踪侦听器(Trace.Listeners.Add(new DiagnosticMonitorTraceListener())。 - 从Web应用程序中写入一些日志。这可能会触发WADLogsTable的创建。