如何为 HttpClient 调用配置网络跟踪 Dotnet 核心? [英] How to Configure Network Tracing Dotnet core for HttpClient calls?

查看:30
本文介绍了如何为 HttpClient 调用配置网络跟踪 Dotnet 核心?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 https://docs.microsoft.com/en-us/dotnet/framework/network-programming/how-to-configure-network-tracing

我们可以在 web.config 或任何其他配置文件中进行设置,我们可以获得详细的 system.net 跟踪、HttpClient 调用的数据包跟踪以及 HttpClient 中的任何类型的问题> 可以在跟踪中捕获调用,无论是证书、TLS 还是其他任何内容.

但是,我们是否有类似的 dotnet 核心/标准实现,可以在 Web 应用程序或控制台应用程序/库中使用?

dotnet 框架的配置:

<预><代码><配置><系统诊断><来源><source name="System.Net" tracemode="includehex" maxdatasize="1024"><听众><add name="System.Net"/></听众></来源>-----------------------------

解决方案

.NET Core 使用 EventSource 来记录这些事件.在 Windows 上,事件源使用 Windows 事件跟踪 (ETW) 所以所有使用它的工具都可以用来记录和读取跟踪输出.在 Linux 上,LTNG 用于记录事件.

Microsoft 的 CoreFX 存储库 包含适用于 Windows 的文档 关于如何使用 PerfViewlogman.他们的 CoreCLR 存储库包含 有关捕获跟踪的文档在 Linux 上,这也很有用.

Microsoft 正致力于以某种方式统一跨平台的体验.目前,这种支持似乎是通过 dotnet 进行的-trace 命令.

您没有直接提到 ASP.NET Core,所以我假设您的问题不是针对它的,但请注意,正如 Alexandre 指出的那样,跟踪可以配置,并且可能提供您需要的部分或全部内容.

As per reference document at https://docs.microsoft.com/en-us/dotnet/framework/network-programming/how-to-configure-network-tracing

We can setup this in web.config or any other configuration file and we get detailed system.net traces, packets traces for HttpClient calls and any kind of issue in HttpClient calls can be captured in traces, be it certificate, TLS or anything else.

However, do we have similar implementation for dotnet core / standard which can be used in both web app or console app/ libraries ?

Configuration for dotnet framwork :

<configuration>  
  <system.diagnostics>  
    <sources>  
      <source name="System.Net" tracemode="includehex" maxdatasize="1024">  
        <listeners>  
          <add name="System.Net"/>  
        </listeners>  
      </source>  
      --------------
----------------------

解决方案

.NET Core uses EventSource to record these events. On Windows the event source uses Event Tracing for Windows (ETW) so all tools that work with it can be used to record and read through the trace output. On Linux, LTTNG is used to record the events.

Microsoft's CoreFX repository contains documentation for Windows on how to debug network traces using both PerfView and logman. Their CoreCLR repository contains documentation on capturing traces on Linux that is also useful.

Microsoft is working on unifying the experience across platforms in a way. At the moment this support seems to be happening through the dotnet-trace command.

You didn't mention ASP.NET Core directly, so I will presume your question isn't specific to it, but note that as Alexandre pointed out, tracing can be configured and may provide some or all of what you need.

这篇关于如何为 HttpClient 调用配置网络跟踪 Dotnet 核心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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