我如何使用Owin Katana Logger [英] How do I use Owin Katana Logger

查看:87
本文介绍了我如何使用Owin Katana Logger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Microsoft Owin项目中的类似文件中看到一个记录器被称为

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?

推荐答案

默认情况下,Katana使用.NET中的TraceSource机制进行日志记录.将以下代码段添加到您的配置文件中,以启用对文件的日志记录:

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>

您可以使用Katana的默认日志记录基础结构,并根据需要进行修改.这是非常详细的帖子解释了Katana的日志记录基础结构,并概述了如何将Owin/Katana日志记录添加到您的项目中.它还包含 Github示例,您可以参考.

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.

查看全文

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