我有一个对象:
var people = new List<Person> {
new Person { Name = "John Doe", Age = 30 },
new Person { Name = "Jane Doe", Age = 25 } };
logger.LogInformation(“{@people }",people);
serilog/elasticsearch日志记录创建以下日志:
[Person { Name: "John Doe", Age: 30 }, Person { Name: "Jane Doe", Age: 25 }]
但我需要以下文件
[{"Name":"John Doe","Age":30},{"Name":"Jane Doe","Age":25}]
我应该如何删除日志实体类型?
1条答案
按热度按时间uemypmqf1#
你可以创建一个匿名对象来实现这一点:
在选择对象之后,需要序列化此列表。