.net - Windows Azure : Can't see trace listener's output in diagnostics logs

标签 .net azure azure-storage azure-blob-storage azure-diagnostics

我想在 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/

相关文章:

.net - 加载 Azure 存储 2.0 时出错 - 无法加载 Microsoft.Data.OData 5.0.2

iphone - 使用 Objective C 将文件读取/写入到 Windows Azure 存储

c# - 使用 (var connection = new SqlConnection ("ConnectionString")) 是否仍然关闭/处理错误连接?

azure - Azure Blob 存储是否支持用于引用位置或文件的别名?

azure - 具有多个应用程序的应用程序洞察

javascript - 如何从 Windows Azure 服务器脚本中插入的项目中获取自动生成的 ID?

.net - 什么是 .net 动态数据,为什么要使用它?

.net - 如何在我的应用程序上启用 .Net Native?

.net - MonoTorrent - Torrent 文件的磁力链​​接

c# - azure documentdb 创建文档重复项 Id 属性