.NET 6 added the ability for us to capture server access logs in W3C extended log file format (IIS default) from our web apps.
To configure we need to register the service with the dependency injection container in .NET and add the middleware to our middleware pipeline as shown on lines 9-13 and line 29 below. We do this in Program.cs. Note that Startup.cs is gone as of .NET 6 (it has been merged into Program.cs)…
Why would we want to configure and capture these logs on an app level rather than server level? Most likely it will be about control. Two things which come to mind are that we may not have access to the server logs or they may not be in W3C format.
Can you think of any other use cases for .NET 6 app level logging?