我可以在OWIN中启用跟踪吗? [英] Can I enable tracing in OWIN?
问题描述
我在OWIN的某个地方遇到环境问题,我想获得一些有关正在发生的事情的信息.我已经读到我可以启用跟踪,但是找不到有关如何执行跟踪的大量信息.
I have an environmental problem somewhere in OWIN and I want to get some information about what is happening. I have read that I can enable tracing but can't find much information on how to do it.
我已将以下内容添加到我的web.config中,但并不高兴.这可能吗?
I have added the following to my web.config but no joy. Is this possible?
<!-- 1. Enable the switch here. Without this, you get nothing. By default, Katana has "new SourceSwitch("Microsoft.Owin")" at the root level. -->
<switches>
<add name="Microsoft.Owin" value="Verbose" />
</switches>
<!-- 2. Add your shared listeners. -->
<trace autoflush="true" />
<sharedListeners>
<add name="file" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\traces\Microsoft.OWIN.trace.log" />
<add name="console" type="System.Diagnostics.ConsoleTraceListener" />
</sharedListeners>
<sources>
<!-- "Microsoft.Owin" is the SourceSwitch name katana is using at the rootlevel. By enabling this, we are enabling all sub level traces by the components (if we don't change the default trace settings). -->
<source name="Microsoft.Owin">
<listeners>
<add name="file" />
<add name="console" />
</listeners>
</source>
</sources>
推荐答案
不能100%地确定这可以解决您的问题,但是我们可以在以下配置下使用它.以下几行略有不同:
Not 100% sure that this will solve your issue, but we got it working with following config. Slight difference in the following line:
<source name="Microsoft.Owin" switchName="Microsoft.Owin" switchType="System.Diagnostics.SourceSwitch">
请注意,<source>
标记包含一个switchName
(和switchType
)属性,该属性在您的示例中缺失.我认为这条指令将TraceSource与Switch链接在一起并完成整个工作.
Notice that the <source>
tag includes a switchName
(and switchType
) attribute which is missing from your example. I think that this instruction links the TraceSource with the Switch and makes the entire work.
在本例中,我们对Azure网站(和Web作业)使用跟踪侦听器.
In our case, we use trace listeners for Azure Web sites (and web jobs).
<system.diagnostics>
<sharedListeners>
<add name="AzureTableTraceListener" type="Microsoft.WindowsAzure.WebSites.Diagnostics.AzureTableTraceListener, Microsoft.WindowsAzure.WebSites.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="AzureBlobTraceListener" type="Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener, Microsoft.WindowsAzure.WebSites.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="AzureDriveTraceListener" type="Microsoft.WindowsAzure.WebSites.Diagnostics.AzureDriveTraceListener, Microsoft.WindowsAzure.WebSites.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</sharedListeners>
<sources>
<source name="Microsoft.Owin" switchName="Microsoft.Owin" switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="AzureTableTraceListener"/>
<add name="AzureDriveTraceListener"/>
</listeners>
</source>
</sources>
<switches>
<add name="Microsoft.Owin" value="All" />
</switches>
<trace autoflush="true" indentsize="4" />
</system.diagnostics>
这篇关于我可以在OWIN中启用跟踪吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!