Thomas Ardal

Thomas Ardal

Meet Thomas, the founder and developer behind elmah.io. Thomas blogs about everything technical from C# and ASP.NET Core to machine learning.

Denmark
313 posts
Mocking HttpClient requests for C# unit tests

Integrating with an external API is something that I do over and over again. While a lot of APIs have clients built specifically for .NET, spinning up a new HttpClient is at least a monthly pleasure. Calling an API using HttpClient is easy, but unit testing code using a HttpClient ...

"Secret" elmah.io features #2 - Correlate messages from apps

This is the second post in the series about "secret" elmah.io features. While reading the first post before this one is not required, I highly recommend you also check it out. In this post, I'll introduce you to the correlation features available in elmah.io. ...

Testing logging code with Microsoft.Extensions.Logging and FakeLogger

Unit testing is most often used for testing business logic. But what if you want to ensure that your code logs important messages to your log store? In this post, I'll introduce you to FakeLogger and how it can be used to test logging code when using Microsoft. ...

"Secret" elmah.io features #1 - Include source code in errors

This is a new series of blog posts that I have been wanting to write for a while. elmah.io offers a large range of features both through the UI and the list of integrations. While basic error monitoring is used by all of our users, there are features available ...

Validate NuGet packages before publishing from GitHub Actions

A big part of elmah.io is our clients for various web and logging frameworks. All of them are open-source, hosted on GitHub, and available as NuGet packages on nuget.org. I have blogged about building on GitHub Actions in the past. It struck me that I have never actually ...

Dependency Injection using keyed services is finally in ASP.NET

.NET 8 was released lately (at least when this post was written) and it contains lots of excellent features and improvements. A minor improvement that I was very happy to finally see in ASP.NET Core, is dependency injection using keys. A feature that I have been using in other ...

Validate JSON files against schema in Azure DevOps build

JSON files have become part of our daily lives. We use JSON files for all sorts of tasks like settings, defining database schemas, and much more. The other day I found out that invalid JSON files had been pushed to one of our repositories. So, I decided to include JSON ...

Setting up better logging in Azure Functions

We have been using Azure Functions for years. Being able to easily deploy and run code on both Azure App Services and real serverless has been a killer feature for all of our asynchronous jobs and services. Unfortunately, the logging approach provided as part of the default template is not ...

Conditionally add middleware in ASP.NET Core

Some weeks ago I wrote a blog post named How to modify response headers in ASP.NET Core middleware that explained how to set a custom response header in ASP.NET Core middleware. Since writing the post I had MULTIPLE people (okay, it was two people) write and ask how ...