DEV Community

Discussion on: ASP.NET Core request logging middleware

antoniofalcao profile image
Antonio Falcão Jr. • Edited

Hi Thomas Ardal, very nice post!

At this moment, .NET developers starting using the native HTTP logging middleware, take a look too:

using Microsoft.AspNetCore.HttpLogging;

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

HTTP logging provides logs of:

  • HTTP Request information
  • Common properties
  • Headers
  • Body
  • HTTP Response information

To configure the HTTP logging middleware, you can specify HttpLoggingOptions in your call to ConfigureServices():

public void ConfigureServices(IServiceCollection services)
   services.AddHttpLogging(logging =>
       // Customize HTTP logging here.
       logging.LoggingFields = HttpLoggingFields.All;
       logging.RequestBodyLogLimit = 4096;
       logging.ResponseBodyLogLimit = 4096;

kaylumah profile image
Max Hamulyák

Very cool Antonio missed that announcement, will be very usefull :)

thomasardal profile image
Thomas Ardal Author • Edited

Hi Antonio

Agree, HTTP logging looks cool for sure. Played around with it as soon as the recent preview of .NET 6 was released (and even found and reported a bug on it 😂). It will take some time before everyone are on .NET 6, though.