Logging in .NET with Exceptionless

ExceptionlessThere are plenty of options when it comes to logging in .NET.  NLog, log4net, Serilog are a few of the names you have likely heard.   One that I recently stumbled upon was Exceptionless.


Logging shouldn’t be difficult.  But sometimes it sure feels that way.

Generally, all I want to do is record various log messages through my application.  These could be handled or unhandled exceptions, debug logs with unstructured data, or just general informational logs such as feature usage.


Excetionless provides the means to persist all the types of logs that I mentioned above to a remote server.

A central location for persisting all application logs in a distributed environment.

It does so with a very simple API and provides a lot of extensions to hook into many of the existing logging libraries you may already be using.


dashI have a soft spot for nice UI’s.  Call me superficial but it’s often one of the first things I notice when looking at any new service.

The Exeptionless UI is good.  It provides a simple way to view the various log entries along with all kinds of a additional data.

Additional Data

Logging messages as strings.  Those days are over.

Exceptionless provides the ability to tag your logs with additional data.  This is incredibly helpful for troubleshooting various issues.  I will log the IRequest command sent to MediatR when a handler fails.

Event Types

There are many different types of events you can log.  General log messages, feature usage, 404’s and custom events.

Service or Self Host

Exceptionless is OSS.  If you want to self host, you can do so fairly easily.  It requires Elasticsearch and then the web app to be installed behind IIS.

If you prefer to have it hosted as a managed service, they do offer this on exceptionless.io and I would highly recommend checking out this option if that fits your requirements.

Check it out

If you are looking for a new logging library or unhappy with what you are currently using, I highly recommend giving Exceptionless a try.  With their free hosted solution, its really easy to get a feel for how the service works and if it fits your requirements.


Let me know if you are using Exceptionless or another logging library.  Please share in the comments below or on twitter.

Windsor-Essex .NET Developers

I started a .NET Developers group in Windsor-Essex.  Why? Well first a bit of back story.

I first started using .NET with C# around 2003-2004 with .NET 1.1.   At the time I was primary using Linux as my desktop and writing PHP and Python and creating web apps.

However, I was required to create a Native Win32 app.  I had used Delphi and Object Pascal just prior but decided to use take the .NET route.Windsor-Essex .NET Developers

Fast forward 13 or so years and I’m still using and for the most part enjoying the ride.


A lot has changed in the past 13 years or so since I first started using it.  Coming from a Linux and OSS communities in Python and PHP to a more closed world in .NET felt very odd.  Simple things like finding code samples or libraries that were OSS were few and far between.   Everything was commercial.

But slowly, over time the OSS community has grown and has developed a not only some great software, but has really started to form a community that I felt early in my career with other languages.

Yes there is still a ton of work to be done. It’s likely the majority of .NET developers are stuck in a Microsoft only bubble, but I do think that’s changing.


I do think being in a Microsoft bubble is a bad thing.  I don’t say that as a negative towards Microsoft.  What I mean is that limiting yourself to only the framework, libraries and tools that are produced by Microsoft is incredibly limiting.  Hammer, meet nail.

But Microsoft’s turn to OSS is refreshing.  Yes they have struggle at times but I do truly believe their underlying intention is good.

Windsor-Essex .NET Developers

I’ve decided to start a .NET Developers group in Windsor-Essex.  This has been in my mind for around the last 5 years or so.

I finally decided to take action because I think with the release .NET Core and the open community that is slowly being built is a kind of renaissance for .NET

Exploring the use of .NET for building and deploying applications on any platform. Our focus will be on the various .NET Platforms (Full Framework, Core, Mono), OSS libraries and various development concepts.  The purpose of this group is to create a great social group in Windsor-Essex where we learn from each other.

If you are in the Windsor or Essex County area, please join our Meetup page.

We will be having monthly meetups on the first Tuesday of each month at Hackforge (255 Ouellette Ave)

User Groups

My biggest challenge with organizing is getting speakers.  If you run or attend a .NET user group and have suggestions on different ways to attract local speakers or any feedback in general, please let me know in the comments on twitter.

Mediator Pattern with Hangfire

Mediator Pattern with HangfireI’ve run into situations where I need to perform actions requested by the client that may take a bit of time.  The length of time could be variable and I don’t want to have the client waiting for a response.  Let’s take a look at using the Mediator Pattern with Hangfire as a solution to this problem.

In a Web API scenario, the request may come in as a PUT or POST from the client. The API would validate the request, send the task to a queue and then return the client a 202 HTTP status code.

The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. There is no facility for re-sending a status code from an asynchronous operation such as this.

This way we can handle the work in another process or thread from the initial request.

Hangfire & MediatR

I’ve posted about MediatR before, a nice library that implements the Mediator Pattern for in-process messaging.  I use it for both handling both Commands and Queries.  For our purposes with Hangfire, it will be used for sending requests that are Commands.

I’ve also previously posted about Hangfire, a really great library in .NET for executing background tasks in all types of .NET applications.  If you are interested in Hangfire, take a look at this post first.

Combining these two libraries allows us to take MediatR out of process and use the same implementation we are used to using in-process.


Hangfire provides the ability for your task to be a method on a class.

However, the above will not work as there is an issue with serializing the Command.

The issue appears to be with MediatR’s Send<Unit> method.  Trying to serialize the expression when it contains a type parameter may be the issue.  If you are aware of what this specific issue is, please let know in the comments.

Since we are using commands that have no return type I just created a static helper function.


Also, in order for serialization to be correct we must set the Json.NET TypeNameHandling setting.

Setting to include type information when serializing JSON and read type information so that the create types are created when deserializing JSON.


So let’s put this simple example all together.

I’m putting the Hangfire server where I’m also creating the task (client).  Because of this, I’m printing out which thread is sending the task, as well as which thread the task is executed on.  If you were running multiple Hangfire server instances, this would happen on any one of them and allows you to distribute tasks.

The resulting output displays that the task was sent from Thread 8 and was executed on Thread 18.

Mediator Pattern with Hangfire



Let me know if you are using MediatR or the Mediator Pattern with Hangfire and how you have implemented it.  Please share in the comments below or on twitter.

Related Posts

Here are some other posts that relate to Hangfire or MediatR that I have written.