# Migrating from Serilog.Sinks.Elasticsearch to Elastic.Serilog.Sinks

**URL:** <https://discuss.elastic.co/t/migrating-from-serilog-sinks-elasticsearch-to-elastic-serilog-sinks/361736>\
**Category:** Elastic Observability\
**Created:** [June 19, 2024, 1:47pm UTC](https://discuss.elastic.co/t/migrating-from-serilog-sinks-elasticsearch-to-elastic-serilog-sinks/361736 "2024-06-19T13:47:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rudolf13](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rudolf13/32/122428_2.png) [@rudolf13](https://discuss.elastic.co/u/rudolf13)\
**Post date:** [June 19, 2024, 1:47pm UTC](https://discuss.elastic.co/t/migrating-from-serilog-sinks-elasticsearch-to-elastic-serilog-sinks/361736/1 "2024-06-19T13:47:28Z")

</div>

```auto
public static IHostBuilder ConfigureLogging(this IHostBuilder hostBuilder)
{
	return hostBuilder.UseSerilog((context, services, configuration) =>
	{
		configuration.WriteTo.Console()
					 .WriteTo.Debug()
					 .WriteTo.Email()
					 .WriteTo.Elasticsearch(
					   autoRegisterTemplate: true,
					   indexFormat: $"random-{{0:yyyy.MM.dd}}",
					   inlineFields: true,
					   nodeUris: "https://username:passwort@elastic-sink.com",
					   restrictedToMinimumLevel: LogEventLevel.Warning
					 );
	});
}

```

I failed to find a way to configure the indexFormat using the Elastic.Serilog.Sinks package. Have anyone an idea how to do that using Elastic.Serilog.Sinks package?

---

<div class="post-metadata">

**Author:** ![rtwolfe94022](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rtwolfe94022/32/132253_2.png) [@rtwolfe94022](https://discuss.elastic.co/u/rtwolfe94022)\
**Post date:** [June 19, 2024, 2:06pm UTC](https://discuss.elastic.co/t/migrating-from-serilog-sinks-elasticsearch-to-elastic-serilog-sinks/361736/2 "2024-06-19T14:06:52Z")

</div>

Official Elastic Search 8.14 + Docker 4.30 Repo via JARaaS Hybrid RAG - Documentation - code current 6/19/2024 [AI Generated]

**Note: Sources at the end of the response**

Migrating from Serilog.Sinks.Elasticsearch to Elastic.Serilog.Sinks indeed presents some configuration challenges, especially regarding settings like `indexFormat`. While `Elastic.Serilog.Sinks` might diverge in certain configurations, it's crucial to consult the package documentation for specific options available.

Here are steps and points to consider when migrating and configuring `indexFormat`:

### Step-by-Step Migration

1. **Identify Configuration Differences** :  
Notice if `Elastic.Serilog.Sinks` provides a direct way to set properties such as `indexFormat`. The documentation will usually specify these details.

2. **Updating Configuration Syntax** :  
Often, packages will have different syntax or method names for configuration settings. You need to update your configuration method to match the new package's API.

3. **Example Migration** :  
Here's a hypothetical migrated method assuming direct property mapping:

### Important Considerations:

1. **Consult Documentation** :  
Always refer to [Elastic.Serilog.Sinks documentation](https://elastic.github.io/serilog-sinks-elasticsearch/) for precise configuration details and any differences between versions or packages.

2. **Logging Endpoint and Authentication** :  
Ensure the `nodeUris` and authentication details are correctly set up to avoid connection issues.

3. **Template Registration** :  
Understand if `autoRegisterTemplate` works similarly or if additional steps are required (e.g., pre-registering templates manually).

Sources:

- [Logging Configuration: logging-config.asciidoc (internal document)]

---

<div class="post-metadata">

**Author:** ![rudolf13](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rudolf13/32/122428_2.png) [@rudolf13](https://discuss.elastic.co/u/rudolf13)\
**Post date:** [June 19, 2024, 2:46pm UTC](https://discuss.elastic.co/t/migrating-from-serilog-sinks-elasticsearch-to-elastic-serilog-sinks/361736/3 "2024-06-19T14:46:04Z")

</div>

I'm sorry, but that's not really helpful. The problem is that the differences between the APIs are huge. I'm not sure if the Elastic.Serilog.Sinks implements the IndexFormat function. I am not aware of any extension point from which I can add the missing functionality to the package.  
I believe that AI generated content will not work because the package is new and there are not that many examples.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Bhamjee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmed_bhamjee/32/124795_2.png) [@Ahmed\_Bhamjee](https://discuss.elastic.co/u/Ahmed_Bhamjee)\
**Post date:** [August 14, 2024, 10:57am UTC](https://discuss.elastic.co/t/migrating-from-serilog-sinks-elasticsearch-to-elastic-serilog-sinks/361736/4 "2024-08-14T10:57:47Z")

</div>

I struggled to get `Elastic.Serilog.Sinks` to log to the data stream which I had created and only after looking at the output of `Serilog.Debugging.SelfLog.Enable` and `channel.ExportResponseCallback` did I realise that the data stream name is the concatenation of the three arguments passed to `Elastic.Ingest.Elasticsearch.DataStreams.DataStreamName(type,dataset,namespace)` (hypen delimited, e.g. "type-dataset-namespace").

In addition, the user configured to write the logs needs to have the monitor cluster privilege (to ping) and index, create\_index, write privileges for the index being written to.

I hope this helps others switching to this sink.

---

<div class="post-metadata">

**Author:** ![Abdullah\_Balikci](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdullah_balikci/32/137128_2.png) [@Abdullah\_Balikci](https://discuss.elastic.co/u/Abdullah_Balikci)\
**Post date:** [August 28, 2024, 6:12pm UTC](https://discuss.elastic.co/t/migrating-from-serilog-sinks-elasticsearch-to-elastic-serilog-sinks/361736/5 "2024-08-28T18:12:33Z")

</div>

Hello, I shared an article on how to use the new package. you can read. If you have any problems, you can contact me.

 ![medium](https://us1.discourse-cdn.com/elastic/original/3X/2/8/2895853855890ad50871eeae8c737ad56196c520.png)

If you type the following into the browser, you can access the relevant article. The article is on Medium.  
How to Migrate from Serilog.Sinks.Elasticsearch to Elastic.Serilog.Sinks on .NET Core: A Step-by-Step Guide.  
Link sharing is not possible.

---

<div class="post-metadata">

**Author:** ![vralchenko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vralchenko/32/139593_2.png) [@vralchenko](https://discuss.elastic.co/u/vralchenko)\
**Post date:** [November 29, 2024, 2:16pm UTC](https://discuss.elastic.co/t/migrating-from-serilog-sinks-elasticsearch-to-elastic-serilog-sinks/361736/6 "2024-11-29T14:16:54Z")

</div>

I attempted to read the article, but it's behind a paywall and I can't see the full content. If you have access, could you copy and paste it here or email it to me?

---

<div class="post-metadata">

**Author:** ![vralchenko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vralchenko/32/139593_2.png) [@vralchenko](https://discuss.elastic.co/u/vralchenko)\
**Post date:** [November 29, 2024, 2:24pm UTC](https://discuss.elastic.co/t/migrating-from-serilog-sinks-elasticsearch-to-elastic-serilog-sinks/361736/7 "2024-11-29T14:24:19Z")

</div>

Found on archive.is/9tfRC

---

<div class="post-metadata">

**Author:** ![Abdullah\_Balikci](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdullah_balikci/32/137128_2.png) [@Abdullah\_Balikci](https://discuss.elastic.co/u/Abdullah_Balikci)\
**Post date:** [April 18, 2025, 2:34pm UTC](https://discuss.elastic.co/t/migrating-from-serilog-sinks-elasticsearch-to-elastic-serilog-sinks/361736/8 "2025-04-18T14:34:36Z")

</div>

> [@vralchenko](#):
>
> archive.is/9tfRC

Thank you, I did this to share quickly because I was busy. I'm sorry.
