Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

318
Views
Reducing HttpClient log verbosity

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?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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"
    }
  },
  "AllowedHosts": "*"
}

Changing the Default to "Warning" or "Error" (or higher) will remove the lower-level messages (such as the Information messages you are getting).

over 4 years ago · Santiago Trujillo Report

0

I managed to exclude these logs using Serilog, which I was already using in the application.

When setting up the LoggerConfiguration, you can apply "filters", like so:

Log.Logger = new LoggerConfiguration()
    .Filter.ByExcluding("SourceContext like '%System.Net.Http.HttpClient%' and @l = 'Information'")
    .CreateLogger();
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!