最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

.net - How to force using existing index in Elastic.Serilog.Sinks - Stack Overflow

programmeradmin4浏览0评论

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

    string indexFormat = settings.IndexName;
    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:

string indexFormat = settings.IndexName;
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 (and hidden) indexes?

发布评论

评论列表(0)

  1. 暂无评论