7

我正在尝试为我在 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 存储?

4

1 回答 1

11

在我最初误读您正在运行 webrole 时进行了编辑 - 哎呀。

使用辅助角色,尝试删除描述日志记录设置的 blob,然后重新部署。您将在用于诊断的存储帐户中的 wad-control-container blob 目录下找到该 blob。

以下是我的原始回复,但它仅适用于您运行 webrole 的情况。我把它留在这里,因为这是一个明显的问题,所以也许它可以为某人节省一些时间:

这可能是因为您的 webrole.cs 代码在与 Web 应用程序不同的 AppDomain 中运行(如果您在完整的 IIS 中托管)。即使在 web.config 中配置了 Azure DiagnosticMonitorTraceListener,它对运行 webrole.cs 代码的 AppDomain 也没有影响。因此,Azure 诊断跟踪侦听器未在 Run 方法中注册,并且跟踪无处可去。

我会尝试两件事: - 在 OnStart (Trace.Listeners.Add(new DiagnosticMonitorTraceListener()) 的代码中显式添加 Azure 诊断跟踪侦听器。 - 从 Web 应用程序写入一些日志。这可能会触发 WADLogsTable 的创建.

于 2012-11-24T09:45:07.747 回答