我想在 Windows Azure 诊断中使用跟踪监听器记录一些消息。我可以看到诊断在我的永久存储上创建的 blob,但看不到跟踪监听器的输出。
这是我在辅助角色 onStart 方法中的尝试:
var config = DiagnosticMonitor.GetDefaultInitialConfiguration();
config.Logs.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(1.0);
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config);
System.Diagnostics.Trace.Listeners.Add(new Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener());
System.Diagnostics.Trace.AutoFlush = true;
System.Diagnostics.Trace.Write("some logging");
最佳答案
您的日志中似乎缺少缓冲区。如果没有可供读取的缓冲区,则不会传输任何内容。尝试添加类似的内容:
config.OverallQuotaInMB = 4096;
config.Logs.BufferQuotaInMB = 512;
您的角色的诊断 blob(在 wad-control-container 中找到)内容应类似于
<?xml version="1.0"?>
<ConfigRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DataSources>
<OverallQuotaInMB>4096</OverallQuotaInMB>
<Logs>
<BufferQuotaInMB>512</BufferQuotaInMB>
<ScheduledTransferPeriodInMinutes>1</ScheduledTransferPeriodInMinutes>
<ScheduledTransferLogLevelFilter>Information</ScheduledTransferLogLevelFilter>
</Logs>
....
关于.net - Windows Azure : Can't see trace listener's output in diagnostics logs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15712672/