Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 如何查看Azure Worker角色的诊断跟踪?_.net_Logging_Azure_Trace_Diagnostics - Fatal编程技术网

.net 如何查看Azure Worker角色的诊断跟踪?

.net 如何查看Azure Worker角色的诊断跟踪?,.net,logging,azure,trace,diagnostics,.net,Logging,Azure,Trace,Diagnostics,我对Azure跟踪日志有疑问。 我有一个工作者角色,我想记录某些事件 当我们在本地部署应用程序时,我们可以使用大脑云存储读取跟踪。 但当我们部署到保留或生产时,我们不能。我们使用相同的存储帐户 工人代码: public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 1

我对Azure跟踪日志有疑问。 我有一个工作者角色,我想记录某些事件

当我们在本地部署应用程序时,我们可以使用大脑云存储读取跟踪。 但当我们部署到保留或生产时,我们不能。我们使用相同的存储帐户

工人代码:

public override bool OnStart()
{
        // Set the maximum number of concurrent connections
        ServicePointManager.DefaultConnectionLimit = 12;

        DiagnosticMonitorConfiguration diagnosticMonitorConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();
        diagnosticMonitorConfiguration.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);
        diagnosticMonitorConfiguration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
        CloudStorageAccount cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
        DiagnosticMonitor diagnosticMonitor = DiagnosticMonitor.Start(cloudStorageAccount, diagnosticMonitorConfiguration);
        return base.OnStart();
    }

     public override void Run()
    {
        // This is a sample worker implementation. Replace with your logic.
        Trace.WriteLine("UpdateWorker entry point called", "Information");

        while (true)
        {
            Thread.Sleep(5000);
            Trace.WriteLine("Working", "Information" + DateTime.Now);
        }
    }
App.config

        <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
        <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>
      </configuration>

我们应该去哪里?这个代码有问题吗


谢谢

我认为问题就在你的身上

CloudStorageAccount cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;

您正在引用计算机上的本地开发存储,该存储在云中运行时将不可用。使用到Azure存储的正确连接字符串,并使用该字符串将日志写入。

可能是您忘记添加Azure存储连接字符串了 “ServiceConfiguration.cscfg”文件

<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=<Storage Account Name>;AccountKey=<Storage Account Key>" />
</ConfigurationSettings>


试试DbgView.exe实用程序,一切看起来都正常。是否确实已将连接字符串更改为以https开头而不是“UseDevelopmentStorage=true”的内容?此处有一篇关于Azure日志记录的有用MSDN文章: