I'm currently writing a .NET 6 application which makes some REST calls.
For some reason, when these calls are made, HttpClient is logging the following:
[15:33:15 INF] Start processing HTTP request GET URL_GOES_HERE
[15:33:15 INF] Sending HTTP request GET URL_GOES_HERE
[15:33:15 INF] Received HTTP response headers after 70.5393ms - 200
[15:33:15 INF] End processing HTTP request after 73.441ms - 200
Due to the number of calls I'm making, this is making my logging platform hard to navigate.
I can't find any documentation online as to how I'd go about muting these logs. They seem to be new to .NET 6? At least I haven't seen them before starting this new project.
I found this github repo which solves this problem, however, I'd rather not pull a third-party package in just to silence some logs.
I have other "information" level logs in my application, meaning I'm unable to suppress the entire level.
Is there really no native way to silence these logs from HttpClient?
Log settings are set in your appsettings.json file (or the appsettings.development.json file):
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"System.Net.Http.HttpClient": "Warning"
}
},
"AllowedHosts": "*"
}
Changing the Default to "Warning" or "Error" (or higher) will remove the lower-level messages (such as the Information messages you are getting).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With