Configuring logging
As with most features of ASP.NET Core, we can configure logging. The default WebApplicationBuilder
does a lot of that for us, but if we want to tweak the defaults, we can. On top of that, the system loads the Logging
section of the configuration. That section is present, by default, in the appsettings.json
file. Like all configurations, it is cumulative, so we can redefine part of it in another file or configuration provider.
We won’t dig too deep into customization, but it is good to know that we can customize the minimum level of what we are logging. We can also use transformation files (such as appsettings.Development.json
) to customize those levels per environment.
For example, we can define our defaults in appsettings.json
, then update a few for development purposes in appsettings.Development.json
, change the production settings in appsettings.Production.json
, then change the staging settings in appsettings.Staging.json
, and add some testing...