gpt4 book ai didi

.net - Azure 诊断 1.3 - 如何在不支持 System.Diagnostics.Trace 的情况下进行日志记录

转载 作者:行者123 更新时间:2023-12-03 03:15:09 26 4
gpt4 key购买 nike

根据Microsoft Azure Diagnostics Part 4: Custom Logging Components and Azure Diagnostics 1.3 Changes :

Azure Diagnostics 1.3 does not support System.Diagnostic.Trace logs. Instead, you are to use EventSource. The System.Diagnostic.Trace logging statements can still be used in the emulated environment to write trace/debug statements to the Azure Compute Emulator console.

我一直在寻找如何在 Azure 中以简单的方式使用 System.Diagnostics ETW(Windows 事件跟踪)框架的示例,就像使用 log4Net 等日志记录框架一样。有没有一种简单的方法可以将 ETW 包装到 log4Net 中的日志附加程序中,以便可以在 Azure 解决方案中编写如下所示的语句。

Log.Info("My info logging statement.")

这应该不难,但我找不到任何简单的示例。

最佳答案

那篇指出 WAD 1.3 不支持 Trace 语句的文章已过时且不再正确。当新版本的 WAD 推出时,它最初不包括对 System.Diagnostics.Trace 的支持,但此后这个问题已得到解决并且应该可以正常工作。要记住的关键一点是,您需要将 2.5 版本的 Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener 注册为跟踪监听器。最简单的方法是将以下内容放入 web.config(对于 IIS 代码)或 app.config(对于辅助角色或 WaIISHost.exe 中的代码):

  <system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>


如果您想使用 ETW 跟踪,您可以查看 http://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-diagnostics/ 中的示例。 。

关于.net - Azure 诊断 1.3 - 如何在不支持 System.Diagnostics.Trace 的情况下进行日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29336692/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com