下面是Serilog的Seq中显示的示例曲线。我希望SensorInput位于详细信息区域,但不会序列化为消息。
如何才能在详细信息区域中显示SensorInput?
var sensorInput = new { Latitude = 25, Longitude = 134 };
Log.Information("Processing {@Payload}", sensorInput);
答案 0 :(得分:2)
Serilog的ForContext()
执行此操作:
var sensorInput = new { Latitude = 25, Longitude = 134 };
Log.ForContext("Payload", sensorInput, true).Information("Processing some data");