ASP.NET Core – Log messages to the database in the background

I was reading about logging in ASP.NET when I came across this statement about logging to the database: When logging to SQL Server, don’t do so directly. Instead, add log messages to an in-memory queue and have a background worker dequeue and insert data to SQL Server. Paraphrased from In this article, I’ll show … Read more

How to use toxiproxy to verify your code can handle timeouts and unavailable endpoints

When you have code that calls an endpoint, you need to make sure it’s resilient and can handle error scenarios, such as timeouts. One way to prove your code is resilient is by using toxiproxy to simulate bad behavior. Toxiproxy sits between your client code and the endpoint. It receives requests from your client, applies … Read more

C# – Exception filters – conditionally catch exceptions

In C# 6 they added exception filtering. This allows you to conditionally catch exceptions. To filter exceptions, you use the when clause after the catch clause, like this: Any SqlException that doesn’t meet the condition will not be caught. Previously, without exception filtering, you’d have to handle that scenario in the catch block and rethrow, … Read more