How to Migrate from Serilog.Sinks.Elasticsearch to Elastic.Serilog.Sinks on .NET Core : A Step-by-Step Guide

Abdullah Balıkçı
Crafterdevs
Published in
3 min readAug 27, 2024

--

Migrating from the Serilog.Sinks.Elasticsearch to the Elastic.Serilog.Sinks package.

The Serilog.Sinks.Elasticsearch package will no longer be supported, which is why a new package has been released by Elastic. To stay up to date, we need to switch to this new package. Since there aren't many applications and resources available, I felt the need to share this. There wasn't enough information in the official documentation, so I designed my implementation by looking at the examples in the GitHub repository. I will provide the current code below, but the main focus is to understand the behavior after running this code. The new package now creates a hidden index for the index you create. You cannot see this index directly in Kibana, so you need to enable the hidden index feature.

Since the information in the documentation is not sufficient, I will update the end of this post as I learn more.

First thing to do is download the new package and delete the old package.

New Package:

dotnet add package Elastic.Serilog.Sinks - version 8.11.1

Another piece of code to focus on here is this:

.WriteTo.Elasticsearch();

The codes written in this code block have changed. Other codes can still be used with Serilog’s existing packages.

--

--