static void

ASP MVC (v3-v5, 2010-2016)

From 2016, see AspNetCore

Links

Tracing

This is the same as normal ASP, but you can't do page output (just Trace.axd).

<system.web>

  <trace enabled="true" writeToDiagnosticsTrace="true" localOnly="true" requestLimit="100" />

Default requestLimit is 10. To redirect System.Diagnostics.Trace to asp.net tracing (Version=2.0.3600.0 in .net 2/3.5, 4.0.0.0 in .net 4/4.5):

<system.diagnostics>
  <trace>
    <listeners>
      <add name="WebPageTraceListener" type="System.Web.WebPageTraceListener, System.Web,
          Version=4.0.0.0, Culture=neutral,
          PublicKeyToken=b03f5f7f11d50a3a" />
    </listeners>
  </trace>
</system.diagnostics>

In Azure Web Sites, you can log to file system ("Application Logging (File System)", set to Error or Verbose. Streaming logs are available in Visual Studio (into the Output Window), via FTP (in the "LogFiles" directory), or in the portal ("Log").

If you use custom logging (log4net, EntLib logging), log to d:\home\logfiles and the streaming still works (probably not through a corporate firewall, though!)

There is also "Application Logging (Storage)" which uses an WAWSAppLogTable Azure table store.

If you deploy to Azure Web Roles, the transform will be:

  <system.diagnostics>
    <trace>
      <listeners>
        <add name="WebPageTraceListener" xdt:Transform="Remove" xdt:Locator="Match(name)" />
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics" xdt:Transform="Insert">
        </add>
      </listeners>
    </trace>
  </system.diagnostics>