无法将日志保存到windows azure表存储?

时间:2014-04-23 12:33:36

标签: c# asp.net-mvc azure azure-storage azure-web-roles

我使用以下代码将跟踪日志保存到表存储中。 我正在使用windows azure skd 2.2版

System.Diagnostics.Trace.TraceError("START Log"); 

还在listener

中添加了web.config
<system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>

还在webrole.cs

中添加了代码
public override bool OnStart()
        {
            StartDiagnostics();
            return base.OnStart();
        }

        private void StartDiagnostics()
        {
            DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();
            TimeSpan tsOneMinute = TimeSpan.FromMinutes(1);
            // Transfer logs to storage every minute
            dmc.Logs.ScheduledTransferPeriod = tsOneMinute;
            // Transfer verbose, critical, etc. logs
            dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Information;
            // Start up the diagnostic manager with the given configuration.
            try
            {
                DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", dmc);
            }
            catch (Exception exp)
            {

            }
        }
  

仍然收到错误:500内部服务器错误

1 个答案:

答案 0 :(得分:0)

您能否确保使用here中的说明正确配置了蔚蓝诊断。如果您在重试后仍然遇到此问题,您可以共享已配置的存储帐户名称(无密钥)并发出此错误吗?