如果我有这个:
logger.Information("this is a message with {property_name}", "value");
我怎么输出这个:
this is a message with property_name = value
代替:
this is a message with value
最佳答案
通过 Serilog 写入的日志消息的显示输出由 formatter 完成由您正在写入的接收器使用。每个接收器都可以使用不同的格式化程序,并且可以不同地表示输出。
您要求的不是默认格式化程序可以做的事情,因此您必须自己编写 custom text formatter ,然后告诉接收器使用您的格式化程序而不是默认的格式化程序。
Formatting Output
Serilog provides several output formatting mechanisms.
- Formatting plain text
- Formatting JSON
- Custom text formatters
关于c# - Serilog 在输出中显示属性名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59126708/