gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 15:29:57 31 4
gpt4 key购买 nike

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

Log.Information("This is the {@object}", new {Prop = "example"})

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

最佳答案

在使用 Serilog 登录到 Elasticsearch 时,可以指定自定义 ITextFormatterElasticsearchSinkOptions 中的属性是:

public ITextFormatter CustomFormatter { get; set; }

您可能需要做一些工作才能按照您想要的方式配置自定义格式化程序 - 子类化 Serilog 的 JsonFormatter,或随接收器提供的 ElasticsearchJsonFormatter,或 fork 创建您自己的,可能会奏效。

关于c# - 是否可以从 Serilog 的输出中删除 _typeTag?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34136358/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com