liveBook · Manning

ILoggingBuilder

As explained in Building Web APIs with ASP.NET Core

ILoggingBuilder is a .NET interface for configuring logging services and providers.

ILoggingBuilder is the configuration surface exposed through WebApplicationBuilder for selecting and customizing logging providers in an ASP.NET Core web API. section 7.2.4

var builder = WebApplication.CreateBuilder(args);
builder.Logging
.ClearProviders()   #1
.AddSimpleConsole()#2
.AddDebug();          #3

Start with the default providers, clear them, then add only the console and debug providers required by the application. section 7.2.4

Configure and verify providers

In Program.cs, call builder.Logging.ClearProviders(), then add the desired providers. A console formatter can enable single-line output, HH:mm:ss timestamps, and UTC time. Launch the MyBGList API in Debug mode, execute BoardGamesController.Get, and check the command prompt for the formatted message. section 7.2.4

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Explains provider removal, re-registration, console options, verification, and appsettings.json configuration without detailing interface internals.
Examples
Uses MyBGList provider selection, console timestamps, UTC formatting, and a BoardGamesController.Get verification message.
What it assumes
Assumes familiarity with Program.cs and WebApplication.CreateBuilder while introducing provider selection and formatter options through concrete steps.
What you can do after
Operate/configure logging providers programmatically and verify formatted output from an API controller.
How it connects
Connects WebApplicationBuilder, ILogger, logging providers, console formatting, Debug logging, and appsettings.json.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.