We have mentioned the diagnostics functionality of ASP.NET Core in Chapter 5, Views. Diagnostics is comparable to logging, but it has a number of advantages, listed as follows:
- Tracing operates on a higher level, capturing a whole journey, not just a moment in time.
- It can do structured logging—that is, it can call methods in the trace loggers that take parameters, not just strings.
- It's easy to plug in new adapters, merely by adding an attribute to a class; even classes in referenced assemblies can be used.
Please refer to Chapter 5, Views, for a more in-depth explanation. Here, we will cover a Microsoft package, Microsoft.AspNetCore.MiddlewareAnalysis. When it is used, it traces all middleware components that execute on the pipeline, through the diagnostics feature. It is configured by a simple call to AddMiddlewareAnalysis, as follows:
services.AddMiddlewareAnalysis();...