启用Azure网站应用程序诊断 [英] Enable Azure Website Application Diagnostics

查看:105
本文介绍了启用Azure网站应用程序诊断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows Azure网站(使用ASP.NET网页构建),并且在配置中为Blob存储和文件存储启用了应用程序诊断":

I have a Windows Azure Website (built with ASP.NET Web Pages), and in the configuration have enabled "Application Diagnostics" for both Blob storage and file storage:

然后我将一些Trace语句添加到Razor页面以对其进行测试

I've then added some Trace statements to a Razor page to test it out

@{
    System.Diagnostics.Trace.TraceInformation("INFORMATION");
    System.Diagnostics.Trace.TraceWarning("WARNING");
    System.Diagnostics.Trace.TraceError("ERROR");
}

但是,这将导致在文件系统或Blob中根本没有日志. 尽管从

However, this results in no logs at all, either in the file system or the blob. For good measure I attempted to add various settings to my web.config file (shown below), although from the documentation I read, it doesn't seem as though this should be necessary. But it makes no difference - I still see no diagnostic logs in the file system or the blob.

  <system.web>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>
    <trace enabled="true"/>
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
     name="AzureDiagnostics">
        </add>
        <add name="WebPageTraceListener"
             type="System.Web.WebPageTraceListener, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
      </listeners>
    </trace>
  </system.diagnostics>

我还需要配置其他我错过的东西吗?难道这对于ASP.NET Web Pages项目根本根本不起作用?

Is there anything else I need to configure that I've missed? Could it be that this simply doesn't work at all for ASP.NET Web Pages projects?

推荐答案

要从剃须刀页面启用跟踪,请将以下内容添加到您的web.config中: <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/define:TRACE" warningLevel="1" /> </compilers> </system.codedom>

To enable tracing from a razor page add the following to your web.config: <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/define:TRACE" warningLevel="1" /> </compilers> </system.codedom>

来源: http://blogs.msdn.com/b/webdev/archive/2013/07/16/tracing-in-asp-net-mvc-razor-views.aspx

请注意,在不对web.config进行任何更改的情况下,从cs文件进行跟踪应该可以工作.

Note that tracing from your cs files should work without any changes to web.config.

这篇关于启用Azure网站应用程序诊断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆