How to Configure Network Tracing Dotnet core for HttpClient calls?

落爺英雄遲暮 提交于 2019-12-06 05:22:48

.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.

Alexandre L.

Everything is explained in the documentation : https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-2.2#logging-1.

In summary, you need to setup "Trace" logging level in appsettings.json and you should see the logs (if you register the HttpClient like this : https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-2.2#basic-usage) :

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