Network tracing on .Net 5 with Nlog

Viewed 138

so the old way for .Net framework to get the network traces does not work anymore. So how do we enable it now?

I've tried the logical thing, listening with nlog for right events, setting Nlog like this(appsettings.json is empty):

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwConfigExceptions="true">
<targets async="true">
    <target name="basic" xsi:type="File" fileName="//share/Logs/netTrace/${shortdate}.txt" layout="${longdate} ${message} ${exception:format=ToString}" keepFileOpen="true" encoding="utf-8" />
</targets>
<rules>
    <logger name="System*" minlevel="Trace" writeTo="basic" final="true" />
    <logger name="Microsoft*" minlevel="Trace" writeTo="basic" final="true" />
</rules>

And building the logger:

return Host.CreateDefaultBuilder(args)
                .ConfigureLogging(logging =>
                {
                    logging.ClearProviders();
                    logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
                    logging.AddNLog(logConfig);
                })

But I still dont get any of the network traces, just very simple logs like this:

2021-09-23 09:23:18.1163 Sending HTTP request POST http://......

No details on sockets, SSL handshake etc... I cant find any information on this problem. Thanks for help.

0 Answers
Related