liveBook · Manning

AddHttpLogging

As explained in ASP.NET Core in Action, 3e

AddHttpLogging is an ASP.NET Core extension method that registers HTTP logging services and configures their options.

AddHttpLogging is an ASP.NET Core extension method that registers the services required by HTTP logging middleware and configures its options. Call it through WebApplicationBuilder.Services before using HTTP logging. section 3.7.1

Configure logged request fields

builder.Services.AddHttpLogging(opts => opts.LoggingFields = HttpLoggingFields.RequestProperties); section 3.7.1

builder.Services.AddHttpLogging(opts =>
   opts.LoggingFields = HttpLoggingFields.RequestProperties);

View the compact registration example showing how an options callback selects the HTTP fields to log. section 3.7.1

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains extension-method registration and option customization, but stops short of detailing dependency inversion or IoC internals.
Examples
Uses an options callback to select RequestProperties through HttpLoggingFields.
What it assumes
Assumes familiarity with Program.cs, WebApplicationBuilder.Services, and registering services in an IoC container.
What you can do after
Configure HTTP logging by registering its services and selecting the middleware fields to display.
How it connects
Connects HTTP logging middleware with WebApplicationBuilder, IServiceCollection, dependency injection, and logging filters.

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.