I output my logged data to both Console
and Seq
sinks. Works great.
When I log a POCO to:
Console
sink, it a long text line with all the properties and the data.Seq
sink, it's nicely structured so it's easy to search/filter/etc.Now, is there a way so that when we output the value to the Console sink, it might use the ToString() method of the POCO (instead of -all- the properties) while to Seq it's exactly what it is, now?
I'm just experimenting right now - some classes don't have an overriden ToString() so that means I will just get the class name there.
Is this possible?
Serilog captures each event property exactly once, and at that point chooses either ToString()
or structured representation.
It's only later in the logging pipeline that events reach sinks like Console
and Seq
, so there's no way for an individual sink (or configuration for a sink) to influence how a particular property value is captured.