Search code examples
loggingserilogseqseq-logging

Serilog - show object in details area, but not in summary message


Below is a sample trace as shown in Seq from Serilog. I would like the SensorInput to be in the details area, but not serialized as the message.

How can I have SensorInput show only in the details area?

        var sensorInput = new { Latitude = 25, Longitude = 134 };
        Log.Information("Processing {@Payload}", sensorInput);

enter image description here


Solution

  • Serilog's ForContext() does this:

        var sensorInput = new { Latitude = 25, Longitude = 134 };
        Log.ForContext("Payload", sensorInput, true).Information("Processing some data");