首页 文章

Windows Azure:可以在诊断日志中输出't see trace listener'

提问于
浏览
1

我想在windows azure诊断中使用跟踪侦听器记录一些消息 . 我能够看到诊断在我的永久存储器上创建的blob,但我看不到跟踪侦听器的输出 .

这是我在worker角色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");

2 回答

  • 0

    看起来你在日志上缺少缓冲区 . 如果没有要读取的缓冲区,则无法传输任何内容 . 尝试添加以下内容:

    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>
            ....
    
  • 0

    我写了一篇博客文章,专门用于在Workerroles中启用跟踪 . 你在这里找到它:http://blog.amtopm.be/2014/07/20/azure-diagnostics-how-to-troubleshoot-your-code/

    如果您还有问题,请告诉我 .

相关问题