-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable network tracing in dotnet core #64977
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsI am writing a dotnet core console application that uses the HttpClient to make an HTTPS request that requires a client certificate. In .Net I can enable system diagnostics in the app.config (or web.config) or by getting the logging object at run time through System.Net.Logging namespace and it will output lots of information about the SSL connection. Is there a similar functionality in dotnet core?
|
If you want to get the internal logging, then it's a little bit more involved with .NET Core and newer. Example: using System.Diagnostics;
using System.Diagnostics.Tracing;
internal sealed class HttpEventListener : EventListener
{
protected override void OnEventSourceCreated(EventSource eventSource)
{
// Allow internal HTTP logging
if (eventSource.Name == "Private.InternalDiagnostics.System.Net.Http")
{
EnableEvents(eventSource, EventLevel.LogAlways);
}
}
protected override void OnEventWritten(EventWrittenEventArgs eventData)
{
// Log whatever other properties you want, this is just an example
var sb = new StringBuilder().Append($"{eventData.TimeStamp:HH:mm:ss.fffffff}[{eventData.EventName}] ");
for (int i = 0; i < eventData.Payload?.Count; i++)
{
if (i > 0)
sb.Append(", ");
sb.Append(eventData.PayloadNames?[i]).Append(": ").Append(eventData.Payload[i]);
}
try {
Console.WriteLine(sb.ToString());
} catch { }
}
}
// Keep the listener around while you want the logging to continue, dispose it after.
var listener = new HttpEventListener(_output); |
Thanks |
I am writing a dotnet core console application that uses the HttpClient to make an HTTPS request that requires a client certificate. In .Net I can enable system diagnostics in the app.config (or web.config) or by getting the logging object at run time through System.Net.Logging namespace and it will output lots of information about the SSL connection. Is there a similar functionality in dotnet core?
I have seen the Tracing in .NET 6 but its not giving us the enough information such as wich cipher is used and what are the public and private key for the data encyption etc.
https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-6/#tracing
The text was updated successfully, but these errors were encountered: