Moq: Extension methods (here: LoggerExtensions.LogError) may not be used in setup / verification expressions.

Sometimes when we develop unit tests it’s convenient to check if the tested code wrote something to the log. Is it a good practice to assert that some particular message appeared in the logs? I think there are pros and cons. On the pros side, we can make general assertions like “no errors were written … Read more

Error CS0618: ‘ConsoleLogger’ is obsolete

This is a short note showing my fix to an error I encountered when migrating application from .NET Framework to the most recent (at the moment) .NET 6. I’m just pasting the rough code example of how this can be migrated, because: Custom console logger using old Microsoft.Extensions.Logging.Console 2.1.1 Equivalent custom console logger using newer Microsoft.Extensions.Logging.Console 6.0.0 … Read more

How to query Application Insights with C#

Update: the code example in this article uses an API that is now deprecated. It will only be useful if you are stuck using old NuGet library to query Application Insights. For new code, you should use https://www.nuget.org/packages/Azure.Monitor.Query/ instead. This article does not provide code example on how to use that newer API. Application Insights … Read more