【问题标题】:How to change Serilog field name posted to Elastic Search如何更改发布到 Elastic Search 的 Serilog 字段名称
【发布时间】:2021-08-19 05:22:13
【问题描述】:

我的 serilog 弹性搜索接收器已经开始工作了。我现在的问题是,当日志发布到弹性搜索时,我正在寻找一种方法来覆盖或删除默认的开箱即用字段命名约定。

我的代码中的示例。

Log.Information("{sTest} {sName} , "This is test.", "This is my name");

将被创建的将具有类似 fields.sTest, fields.sName

有没有办法省略“字段”。前缀,只需使用 sTestsName? 谢谢。

【问题讨论】:

    标签: asp.net-core elasticsearch serilog elk serilog-sinks-elasticsearch


    【解决方案1】:

    您需要将InlineFields 属性设置为true

    var loggerConfig = new LoggerConfiguration()
        .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("http://localhost:9200"))
        {
            InlineFields = true,
            ...
        });
    

    【讨论】:

      猜你喜欢
      • 2016-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-01
      • 2018-08-01
      • 2010-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多