Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

360
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda