Did you know that writing your own logging infrastructure code wastes time? There are awesome logging abstractions in .NET Core and .NET 5+ that you should use instead!
These abstractions allow you to:
Read more at Logging in .NET Core and ASP.NET Core
❌ Figure: Bad example - Using Debug or Trace for logging, or writing hard coded mechanisms for logging does not allow you to configure logging at runtime
❌ Figure: Bad example - Roll your own logging components lack functionality, and have not been tested as thoroughly for quality or performance as log4net
_logger.LogInformation("Getting item {Id} at {RequestTime}", id, DateTime.Now);
✅ Good example - Using templates allows persisting structured log data (DateTime is a complex object)
✅ Figure: Good example - Seq provides a powerful UI for searching and viewing your structured logs