是否可以从 Serilog 的输出中删除 _typeTag?

sco*_*ttm 5 c# serilog

我正在使用 Serilog 通过 Logstash 将结构化日志数据写入 Elasticsearch。在像这样的日志消息中写入对象时

Log.Information("This is the {@object}", new {Prop = "example"})
Run Code Online (Sandbox Code Playgroud)

附加属性 _typeTag 包含在输出的 JSON 中。是否可以排除此属性?

Nic*_*rdt 0

ITextFormatter使用 Serilog 登录 Elasticsearch 时可以指定自定义。的财产ElasticsearchSinkOptions是:

public ITextFormatter CustomFormatter { get; set; }
Run Code Online (Sandbox Code Playgroud)

您可能需要做一些工作才能按照您想要的方式配置自定义格式化程序 - 子类化 SerilogJsonFormatterElasticsearchJsonFormatter接收器提供的 ,或分叉以创建您自己的,可能会起作用。