Seq as a Sink for Serilog

As I explained in the last posts, log messages are not just strings but have an inner meaning. When we use Serilog to write structured log messages we make them explicit to query them later. The tool we want to use to search for a specific orderId should give us this capability without the need to write all the code from scratch. We therefore need a tool that understands log messages and, if possible, even Serilog. One such tool is Seq that I explain in this blog post.

This post is part of the Improve Your Log Messages series. You can find the other parts here:

 

Installing Seq

Seq is a commercial tool that will cost you 70$ for 5 users per year. However, you can download a free single-user version to find out if Seq is worth the effort. To start you get the installer from GetSeq.net, answer a few questions and click next till you reach the end:

Seq Wizard

When the installation is completed your browser will open http://localhost:5341/ and point you to the web interface of your freshly installed Seq server. So far you can’t see much, but when the messages arrive this screen will let you look deep into your application. Let’s create some log messages.

 

Using Seq as Sink

To use Seq with Serilog you need to install the NuGet package Seq.Client.Serilog Serilog.Sinks.Seq:

Nuget Seq

If you prefer the command line you can insert this command in the package console to get the same package installed:

 

Configure the Sink

When the client is installed you can configure Serilog to use Seq as a sink. This is even simpler as the RavenDB configuration, then Seq only needs the URL your browser opened after the installation:

When you run your application the log message is written to Seq and will appear after a few seconds in the web interface:

Seq_FirstEvent-t

 

Search your Messages

The event screen in the web interface offers you an overview on all the received events. If you click on one message it will expand and you will find a green checkmark (include) and a red cross (exclude) to filter your messages. When you want to find all the messages related to orderId 123 you only have to click on the checkmark. Seq will create a query string with orderId == 123 and shows you only the messages that satisfy this condition:

Seq Filter

If you want to find another order Id you simply modify this query string. When you need a certain type of entry you can use the context menu of the type field and get all those messages. All you need is to click on some properties and Seq will create filters for your condition.

 

Next

Before we can fully see the benefits of Seq we have to look a bit deeper into Serilog and how we can manipulate the messages it creates. Depending on how you write your calls to the logger the messages will contain more or less useful data. Next week I will show you how @ and $ can influence the usefulness of a log entry.

 
Update on 2014/10/11: Add new package name Serilog.Sinks.Seq.

2 thoughts on “Seq as a Sink for Serilog”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.