# How to specify index name in Elastic.Serilog.Sinks

**URL:** <https://discuss.elastic.co/t/how-to-specify-index-name-in-elastic-serilog-sinks/374741>\
**Category:** Elasticsearch\
**Created:** [February 19, 2025, 9:13am UTC](https://discuss.elastic.co/t/how-to-specify-index-name-in-elastic-serilog-sinks/374741 "2025-02-19T09:13:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Farsi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_farsi/32/141470_2.png) [@Nick\_Farsi](https://discuss.elastic.co/u/Nick_Farsi)\
**Post date:** [February 19, 2025, 9:13am UTC](https://discuss.elastic.co/t/how-to-specify-index-name-in-elastic-serilog-sinks/374741/1 "2025-02-19T09:13:36Z")

</div>

I have switched from Serilog.Sinks.Elasticsearch package to Elastic.Serilog.Sinks. Before I would specify target index name like this:

```auto
	string indexFormat = settings.IndexName.Replace("$ComponentID$", componentId.ToLower().Replace(".", "-"));
	configuration
		.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(settings.ConnectionString))
		{
			MinimumLogEventLevel = logLevel.Value,
			AutoRegisterTemplate = true,
			IndexFormat = indexFormat, // this worked just fine
			BatchAction = ElasticOpType.Create
		});
}

```

This would send logs to the expected index 'qa-stem-backend-log'.

After switching to the Elastic.Serilog.Sinks I scaffold things like this:

```auto
string indexFormat = settings.IndexName.Replace("$ComponentID$", componentId.ToLower().Replace(".", "-"));
configuration.WriteTo.Elasticsearch([new Uri(settings.ConnectionString)], options =>
{
	options.LevelSwitch = new()
	{
		MinimumLevel = logLevel.Value,
	};
	options.DataStream = new DataStreamName(indexFormat); // I set index name here
	options.TextFormatting = new EcsTextFormatterConfiguration();
	options.BootstrapMethod = BootstrapMethod.Failure;
	options.ConfigureChannel = channelOptions =>
	{
		channelOptions.BufferOptions = new BufferOptions();
	};
});

```

However instead of writing to the existing and well known 'qa-stem-backend-log' index it went to create it's own .ds-qa-stem-backend-log-generic-default-2025.01.15-000001.  
How to force it to write logs to the existing 'qa-stem-backend-log' and not create any new indexes?
