Chapter 7: Logging in .NET 5
Logging helps you to record your application's behavior for different data at runtime and you can control what you want to record and where you want to record. Once the development of your feature is complete, you would unit test it thoroughly on a development PC, deploy it in a test environment for thorough integration testing, then deploy it in production, and finally, open it up for a large number of users. The context in which your application is running, such as servers, data, load, and so on, is different in test environments and production environments when you compare it with the development box, and you might face unexpected issues in the test and production environments in the initial days.
This is where logging plays a very important role to record what happens during runtime when different components in the end-to-end flow perform their functions and interact with each other. With the log information available, we can debug production...