How do I use Owin Katana Logger

∥☆過路亽.° 提交于 2020-02-25 03:07:06

问题


I see in files like this within the Microsoft Owin projects a logger is being called

https://github.com/aspnet/AspNetKatana/blob/dev/src/Microsoft.Owin.Security.OpenIdConnect/OpenidConnectAuthenticationHandler.cs

Can anyone tell me how I activate it to actually start writing logs somewhere that I can read?


回答1:


By default Katana uses the TraceSource mechanism in .NET for logging. Add the following snippet to your config file to enable logging 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>

You can use Katana's default logging infrastructure and modify as needed. Here is a very detailed post that explains Katana's logging infrastructure and outlines how to add Owin/Katana logging to your projects. It also contains Github samples that you can reference.

This official Microsoft guide is very helpful as well.



来源:https://stackoverflow.com/questions/51283208/how-do-i-use-owin-katana-logger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!