我使用VisualStudio2010和模拟器工具(2012年6月) 我创建了一个新的工作角色项目。
在 WorkerRole.cs 文件中:
public class WorkerRole : RoleEntryPoint
{
public override void Run()
{
Trace.TraceInformation("Begin loop at " + DateTime.Now);
int i = 0;
while (true)
{
Trace.TraceInformation("I'm in a loop (" + i++ + ") at " + DateTime.Now + ".");
Thread.Sleep(15000);
}
}
private void InitLogs()
{
DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();
config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config);
Trace.TraceInformation("Start at " + DateTime.Now);
}
public override bool OnStart()
{
ServicePointManager.DefaultConnectionLimit = 12;
InitLogs();
return base.OnStart();
}
}
在我的设置中:
Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString = UseDevelopmentStorage=true
在 app.config 中:
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
当我在本地启动调试(F5)时,我可以在 Windows Azure计算模拟器中看到这一点:
[fabric] Role Instance: deployment16(275).WindowsAzureProject2.WorkerRole1.0
[fabric] Role state Started
[Diagnostics]: UpdateState(Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorStartupInfo, Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorConfiguration, )
[runtime] Role entrypoint . CALLING OnStart()
[Diagnostics]: Acquired mutex
[Diagnostics] Information: C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor
[Diagnostics] Information: c:\users\benjamin.lux\documents\visual studio 2010\Projects\WindowsAzureProject2\WindowsAzureProject2\csx\Debug\roles\WorkerRole1\diagnostics\x64\monitor\MonAgentHost.exe -LocalPath "C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor" -StaticConfigFile "C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor\Configuration\mastaticconfig.xml" -ConfigFile "C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor\Configuration\maconfig.xml" -ShutDownEvent WADDM-ShutDown-54bc885b045e40ecaf8474c810199ab5 -InitializedEvent WADM-StartUp-54bc885b045e40ecaf8474c810199ab5 -parent 7656 -events
[Diagnostics]: UpdateState(Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorStartupInfo, Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorConfiguration, )
[Diagnostics]: Mutex already taken
[Diagnostics]: Creating config channel client
[Diagnostics]: Attempting to connect to server...
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:17:40.111Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 6920
[MonAgentHost] Error: 4636
[MonAgentHost] Error: SelfMonitoring
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\agent\dll\selfmon.cpp
[MonAgentHost] Error: MASelfMon::GetProcCntrs
[MonAgentHost] Error: 1421
[MonAgentHost] Error: ffffffffc0000bb8
[MonAgentHost] Error: 0
[MonAgentHost] Error:
[MonAgentHost] Error: PdhAddCounter(\Process(MonAgentHost#0)\ID Process) failed
[Diagnostics]: Creating config channel server
[MonAgentHost] Output: Agent will exit when WADDM-ShutDown-54bc885b045e40ecaf8474c810199ab5 is signaled.
[MonAgentHost] Output: Will signal WADM-StartUp-54bc885b045e40ecaf8474c810199ab5 after the agent is initialized.
[MonAgentHost] Output: Registered as an event consumer.
[MonAgentHost] Output: Agent will exit when parent process 7656 exits.
[MonAgentHost] Output: Monitoring Agent Started
[Diagnostics]: Starting configuration channel polling
[Diagnostics]: Connection sucessful, sending config
[WaWorkerHost.exe] Start at 09/07/2012 10:17:40
[runtime] Role entrypoint . COMPLETED OnStart()
[Diagnostics]: Config request received
[Diagnostics]: Signalling process restart on event = WADDM-ShutDown-54bc885b045e40ecaf8474c810199ab5
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:17:40.662Z
[MonAgentHost] Error: 3
[MonAgentHost] Error: 6920
[MonAgentHost] Error: 4636
[MonAgentHost] Error: SelfMonitoring
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\agent\dll\selfmon.cpp
[MonAgentHost] Error: MASelfMon::StartTerminationCountdown
[MonAgentHost] Error: 1088
[MonAgentHost] Error: 10011
[MonAgentHost] Error: 0
[MonAgentHost] Error:
[MonAgentHost] Error: Not starting termination thread inside a client hosted monitoring agent
[MonAgentHost] Output: Exiting the monitoring agent 6920 after the shutdown event was signaled.
[MonAgentHost] Output: Monitoring Agent Stopped
[Diagnostics] Information: Diagnostic process exited with code: 0
[runtime] Role entrypoint . CALLING Run()
[WaWorkerHost.exe] Begin loop at 09/07/2012 10:17:40
[WaWorkerHost.exe] I'm in a loop (0) at 09/07/2012 10:17:40.
[Diagnostics] Information: C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor
[Diagnostics] Information: c:\users\benjamin.lux\documents\visual studio 2010\Projects\WindowsAzureProject2\WindowsAzureProject2\csx\Debug\roles\WorkerRole1\diagnostics\x64\monitor\MonAgentHost.exe -LocalPath "C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor" -StaticConfigFile "C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor\Configuration\mastaticconfig.xml" -ConfigFile "C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor\Configuration\maconfig.xml" -ShutDownEvent WADDM-ShutDown-5548c4bc522e4f858d6ab6df287747cf -InitializedEvent WADM-StartUp-5548c4bc522e4f858d6ab6df287747cf -parent 7656 -events
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:17:42.930Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 6260
[MonAgentHost] Error: 5472
[MonAgentHost] Error: SelfMonitoring
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\agent\dll\selfmon.cpp
[MonAgentHost] Error: MASelfMon::GetProcCntrs
[MonAgentHost] Error: 1421
[MonAgentHost] Error: ffffffffc0000bb8
[MonAgentHost] Error: 0
[MonAgentHost] Error:
[MonAgentHost] Error: PdhAddCounter(\Process(MonAgentHost#0)\ID Process) failed
[MonAgentHost] Output: Agent will exit when WADDM-ShutDown-5548c4bc522e4f858d6ab6df287747cf is signaled.
[MonAgentHost] Output: Will signal WADM-StartUp-5548c4bc522e4f858d6ab6df287747cf after the agent is initialized.
[MonAgentHost] Output: Registered as an event consumer.
[MonAgentHost] Output: Agent will exit when parent process 7656 exits.
[MonAgentHost] Output: Monitoring Agent Started
[Diagnostics]: Starting configuration channel polling
[WaWorkerHost.exe] I'm in a loop (1) at 09/07/2012 10:17:55.
[WaWorkerHost.exe] I'm in a loop (2) at 09/07/2012 10:18:10.
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:18:15.202Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 6260
[MonAgentHost] Error: 5412
[MonAgentHost] Error: NetTransport
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\shared\nettransport\src\netutils.cpp
[MonAgentHost] Error: OpenHttpSession
[MonAgentHost] Error: 749
[MonAgentHost] Error: 0
[MonAgentHost] Error: 2f94
[MonAgentHost] Error:
[MonAgentHost] Error: WinHttpGetProxyForUrl(http://127.0.0.1) failed ERROR_WINHTTP_AUTODETECTION_FAILED (12180)
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:18:22.313Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 6260
[MonAgentHost] Error: 7912
[MonAgentHost] Error: NetTransport
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\shared\nettransport\src\netutils.cpp
[MonAgentHost] Error: OpenHttpSession
[MonAgentHost] Error: 749
[MonAgentHost] Error: 0
[MonAgentHost] Error: 2f94
[MonAgentHost] Error:
[MonAgentHost] Error: WinHttpGetProxyForUrl(http://127.0.0.1) failed ERROR_WINHTTP_AUTODETECTION_FAILED (12180)
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:18:24.578Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 6260
[MonAgentHost] Error: 7912
[MonAgentHost] Error: NetTransport
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\shared\nettransport\src\netutils.cpp
[MonAgentHost] Error: OpenHttpSession
[MonAgentHost] Error: 749
[MonAgentHost] Error: 0
[MonAgentHost] Error: 2f94
[MonAgentHost] Error:
[MonAgentHost] Error: WinHttpGetProxyForUrl(http://127.0.0.1) failed ERROR_WINHTTP_AUTODETECTION_FAILED (12180)
[WaWorkerHost.exe] I'm in a loop (3) at 09/07/2012 10:18:25.
[Diagnostics]: Checking for configuration updates 09/07/2012 10:18:40.
[WaWorkerHost.exe] I'm in a loop (4) at 09/07/2012 10:18:40.
[Diagnostics]: Signalling process restart on event = WADDM-ShutDown-5548c4bc522e4f858d6ab6df287747cf
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:18:40.731Z
[MonAgentHost] Error: 3
[MonAgentHost] Error: 6260
[MonAgentHost] Error: 5472
[MonAgentHost] Error: SelfMonitoring
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\agent\dll\selfmon.cpp
[MonAgentHost] Error: MASelfMon::StartTerminationCountdown
[MonAgentHost] Error: 1088
[MonAgentHost] Error: 10011
[MonAgentHost] Error: 0
[MonAgentHost] Error:
[MonAgentHost] Error: Not starting termination thread inside a client hosted monitoring agent
[MonAgentHost] Output: Exiting the monitoring agent 6260 after the shutdown event was signaled.
[MonAgentHost] Output: Monitoring Agent Stopped
[Diagnostics] Information: Diagnostic process exited with code: 0
[Diagnostics] Information: C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor
[Diagnostics] Information: c:\users\benjamin.lux\documents\visual studio 2010\Projects\WindowsAzureProject2\WindowsAzureProject2\csx\Debug\roles\WorkerRole1\diagnostics\x64\monitor\MonAgentHost.exe -LocalPath "C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor" -StaticConfigFile "C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor\Configuration\mastaticconfig.xml" -ConfigFile "C:\Users\benjamin.lux\AppData\Local\dftmp\Resources\0f8904a1-352a-4726-a1fc-17fb8d128797\directory\DiagnosticStore\Monitor\Configuration\maconfig.xml" -ShutDownEvent WADDM-ShutDown-88b62f24f2154dbabb56a138a624ff8a -InitializedEvent WADM-StartUp-88b62f24f2154dbabb56a138a624ff8a -parent 7656 -events
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:18:42.920Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 6068
[MonAgentHost] Error: 7820
[MonAgentHost] Error: SelfMonitoring
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\agent\dll\selfmon.cpp
[MonAgentHost] Error: MASelfMon::GetProcCntrs
[MonAgentHost] Error: 1421
[MonAgentHost] Error: ffffffffc0000bb8
[MonAgentHost] Error: 0
[MonAgentHost] Error:
[MonAgentHost] Error: PdhAddCounter(\Process(MonAgentHost#0)\ID Process) failed
[MonAgentHost] Output: Agent will exit when WADDM-ShutDown-88b62f24f2154dbabb56a138a624ff8a is signaled.
[MonAgentHost] Output: Will signal WADM-StartUp-88b62f24f2154dbabb56a138a624ff8a after the agent is initialized.
[MonAgentHost] Output: Registered as an event consumer.
[MonAgentHost] Output: Agent will exit when parent process 7656 exits.
[MonAgentHost] Output: Monitoring Agent Started
[Diagnostics]: Starting configuration channel polling
[WaWorkerHost.exe] I'm in a loop (5) at 09/07/2012 10:18:55.
[WaWorkerHost.exe] I'm in a loop (6) at 09/07/2012 10:19:10.
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:19:15.198Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 6068
[MonAgentHost] Error: 612
[MonAgentHost] Error: NetTransport
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\shared\nettransport\src\netutils.cpp
[MonAgentHost] Error: OpenHttpSession
[MonAgentHost] Error: 749
[MonAgentHost] Error: 0
[MonAgentHost] Error: 2f94
[MonAgentHost] Error:
[MonAgentHost] Error: WinHttpGetProxyForUrl(http://127.0.0.1) failed ERROR_WINHTTP_AUTODETECTION_FAILED (12180)
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:19:22.313Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 6068
[MonAgentHost] Error: 7748
[MonAgentHost] Error: NetTransport
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\shared\nettransport\src\netutils.cpp
[MonAgentHost] Error: OpenHttpSession
[MonAgentHost] Error: 749
[MonAgentHost] Error: 0
[MonAgentHost] Error: 2f94
[MonAgentHost] Error:
[MonAgentHost] Error: WinHttpGetProxyForUrl(http://127.0.0.1) failed ERROR_WINHTTP_AUTODETECTION_FAILED (12180)
[MonAgentHost] Error: MA EVENT: 2012-07-09T08:19:24.577Z
[MonAgentHost] Error: 2
[MonAgentHost] Error: 6068
[MonAgentHost] Error: 7748
[MonAgentHost] Error: NetTransport
[MonAgentHost] Error: 0
[MonAgentHost] Error: x:\btsdx\215\services\monitoring\shared\nettransport\src\netutils.cpp
[MonAgentHost] Error: OpenHttpSession
[MonAgentHost] Error: 749
[MonAgentHost] Error: 0
[MonAgentHost] Error: 2f94
[MonAgentHost] Error:
[MonAgentHost] Error: WinHttpGetProxyForUrl(http://127.0.0.1) failed ERROR_WINHTTP_AUTODETECTION_FAILED (12180)
[WaWorkerHost.exe] I'm in a loop (7) at 09/07/2012 10:19:25.
[WaWorkerHost.exe] I'm in a loop (8) at 09/07/2012 10:19:40.
所以我可以看到跟踪消息0,1,2,3,4,5,6,7和8 但是当我看一下我的“WADLogsTable”时,我只收到消息:开始,1,2,3和4,没有开始,数字0和5,6,7和8 。
拖出主要问题:
它们在哪里?
如果我在拖曳的“转移期”之前停止实例会发生什么?
在这种情况下,我的上一个日志是保存还是我必须使用 DeploymentDiagnosticManager 类强制上传?
第二个问题是因为4个持续时间的消息可能不是问题。
对于 Windows Azure计算模拟器中的信息错误并不重要:blog post
编辑09/07/2012:澄清情况。
编辑 16/07/2012:如果有人可以创建新的辅助角色项目并添加上面的代码,请按F5。我想知道这是个人交易还是模拟器(或其他)的问题。
答案 0 :(得分:0)
根据我的经验,您必须在启动诊断监视器之前使用SetCurrentConfiguration,否则跟踪日志不会传输到WadLogsTable。这将使用当前日志传输时间来移动日志。 您是否还可以添加时间刻度,以便您的日志在创建时查看?