John Livermore
John Livermore

Reputation: 31323

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

Upvotes: 1

Views: 338

Answers (1)

Nicholas Blumhardt
Nicholas Blumhardt

Reputation: 31832

Serilog's ForContext() does this:

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

Upvotes: 2

Related Questions