Skip to content

Debugging

Chris Ross edited this page Jan 30, 2019 · 2 revisions

How do I Debug my Katana based app or framework?

There are several tools available to help you debug your application.

Diagnostics

The Microsoft.Owin.Diagnostics nuget package contains a welcome page and an error page. The UseWelcomePage extensions can be used to add a simple html page to your application to verify the site is up and running. The UseErrorPage extensions can be used to add an Exception filter to the request pipeline that will display exception and request details.

Debug Symbols

Starting with v4.0.1 Katana's debug symbols are now being published to the Microsoft Symbol Server. This will get you improved stack traces and type inspection, but not source stepping. See this issue for future followup.

Logging

The Katana servers and middleware log errors to the .NET trace infrastructure by default. Components log under their full name, including namespace, so logs can be enabled per component, per namespace, or globally for everything in the Microsoft.Owin namespaces. By default logs are sent to the Visual Studio output console during debugging. Here's how to also direct them to a file:

  <system.diagnostics>
    <trace autoflush="true" />
    <sources>
      <source name="Microsoft.Owin">
        <listeners>
          <add name="KatanaListener"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add
       name="KatanaListener"
       type="System.Diagnostics.TextWriterTraceListener"
        initializeData="Katana.trace.log"
       traceOutputOptions = "ProcessId, DateTime"
                />
    </sharedListeners>
    <switches>
      <add name="Microsoft.Owin" value="Verbose" />
    </switches>
  </system.diagnostics>