[英]How does one set JsonSerializerOptions.DefaultIgnoreCondition for Serilog.Sinks.Seq
I'm using Serilog.Sinks.Seq in my C# app (see the configuration code below) but I can't figure out how to set the JsonSerializerOptions.DefaultIgnoreCondition to ignore nulls.我在我的 C# 应用程序中使用 Serilog.Sinks.Seq(请参阅下面的配置代码),但我不知道如何设置 JsonSerializerOptions.DefaultIgnoreCondition 以忽略空值。 Any help in this regard would be greatly appreciated...
在这方面的任何帮助将不胜感激......
using IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
services.AddHostedService<Worker>();
})
.UseSerilog((context, config) =>
{
var seqUri = new Uri(context.Configuration["SeqUri"]!);
var seqApiKey = context.Configuration["SeqApiKey"]!;
config.MinimumLevel.Debug()
.WriteTo.Seq(seqUri.AbsoluteUri, apiKey: seqApiKey);
})
.Build();
await host.RunAsync();
WriteTo.Seq
does not provide any ways to use JsonSerializerOptions
. WriteTo.Seq
不提供任何使用JsonSerializerOptions
的方法。 The Seq server itself is responsible for handling the serialization of the log events. Seq 服务器本身负责处理日志事件的序列化。 It's designed to work with structured log data so it uses its own serialization format which is built for optimization.
它旨在处理结构化日志数据,因此它使用自己的序列化格式来优化。 I'm not aware of anyways to modify or override it.
我不知道无论如何要修改或覆盖它。
You can use other sinks for logging which provide support for custom serialization Serilog.Sinks.File
or Serilog.Sinks.Elasticsearch
.您可以使用其他接收器进行日志记录,这些接收器为自定义序列化
Serilog.Sinks.File
或Serilog.Sinks.Elasticsearch
提供支持。 You can use these sinks to log and then use Log Shipping
to consume those logs in Seq
.您可以使用这些接收器来记录日志,然后使用
Log Shipping
传送在Seq
中使用这些日志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.