ILogger不以JSON格式返回消息和对象

问题描述 投票:1回答:1

我试着用以下方式使用ILogger,

_logger.LogInformation("Logging info {someClass}", someClass);

但输出只是对象名称。

我在这做错了什么?

c# .net-core nlog structured-logging
1个回答
0
投票

您可能希望将类破坏为属性。

这是选择加入,可以使用@启用

所以

_logger.LogInformation("Logging info {@someClass}", someClass);

另见:How to use structured loggingMessage templates specs

© www.soinside.com 2019 - 2024. All rights reserved.