Max*_*Max 11 .net trace azure azure-storage azure-diagnostics
我确定我错过了一些简单的东西,但我无法让简单的Trace.WriteLine在Azure上工作.
我采取的步骤:
Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString已设置为我们的Azure存储帐户
将模块诊断导入服务定义文件.
Web config:
  <system.diagnostics>
    <switches>
      <add name="logLevel" value="4" />
    </switches>
    <trace autoflush="false" indentsize="4">
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          name="AzureDiagnostics">
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
WebRole.cs
public class WebRole : RoleEntryPoint
{
    public override bool OnStart()
    {
        String wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
        CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));
        RoleInstanceDiagnosticManager roleInstanceDiagnosticManager =
                cloudStorageAccount.CreateRoleInstanceDiagnosticManager(
                RoleEnvironment.DeploymentId,
                RoleEnvironment.CurrentRoleInstance.Role.Name,
                RoleEnvironment.CurrentRoleInstance.Id);
        DiagnosticMonitorConfiguration diagnosticMonitorConfiguration =
            roleInstanceDiagnosticManager.GetCurrentConfiguration();
        diagnosticMonitorConfiguration.Directories.ScheduledTransferPeriod =
               TimeSpan.FromMinutes(5d);
        diagnosticMonitorConfiguration.Logs.ScheduledTransferPeriod =
               TimeSpan.FromMinutes(1d);
        diagnosticMonitorConfiguration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
        roleInstanceDiagnosticManager.SetCurrentConfiguration
              (diagnosticMonitorConfiguration);
        Trace.WriteLine("This is the message");
        Debug.Write("This is the debug message");
        System.Diagnostics.Trace.TraceError("message2");
        System.Diagnostics.Trace.TraceWarning("message warning");
        System.Diagnostics.Trace.TraceInformation("message warning");
        Trace.Flush();
        return base.OnStart();
    }
}
解决方案编译为发布.
当我查看存储帐户中的对象时,我可以看到一个名为WADDirectoriesTable的表,并创建了三个名为vsdeploy,wad-control-container和was-iis-logfiles的blob.
没有什么看起来像我的跟踪信息.
非常感谢
对了,排序了!
这篇文章解释了所有内容:http://social.msdn.microsoft.com/Forums/pl-PL/windowsazuredata/thread/d3f2f1d7-f11e-4840-80f7-f61dc11742fb
这是因为在 Azure SDK 1.3 及更高版本中,webrole.cs 文件中的侦听器与 Web 应用程序的其余部分不同,因为它完全在 IIS 中运行。如果我将跟踪项添加到 Web 应用程序本身,则 WADLogsTable 表会显示我的跟踪信息。
| 归档时间: | 
 | 
| 查看次数: | 10034 次 | 
| 最近记录: |