Posts about Logging

Request ID middleware in ASP.NET Core

February 2nd 2024 Logging .NET Azure

In a previous post, I wrote about the built-in log correlation features for ASP.NET Core when logging to Application Insights. But what if you want to log elsewhere or want more control over the correlation ID? A custom middleware could be all you need.

ASP.NET Core log correlation in Azure

January 19th 2024 Logging .NET Azure

If you're hosting your ASP.NET Core application in Azure, you're most likely collecting your logs in Application Insights. Make sure you configure the logging in your application correctly to take advantage of built-in support for per-request log correlation.

Benefits of structured logging

January 12th 2024 Logging .NET Azure

After you create a new .NET 8 project, you'll soon notice many new diagnostics being enabled by default. If you're using string interpolation in your logging calls, it will now result in code suggestions in your error list.

Unit Testing log4net Logging Code

January 20th 2014 Logging Unit Testing

There's usually no need to unit test the logging code. If you just want to ignore it in your tests, there's nothing you need to do when using log4net. If you want to make sure you're going to log the right information, you can use MemoryAppender in your unit tests.