Is there a way to make Serilog format structured data into a formatted output?
I've been using structured data structures in Serilog lately and even though there is an advantage of it being compact large data structures (5 properties or more) are hard to read in the console/file without formatting it later.
Hypothetically I'd only enable this on dev.
https://github.com/serilog/serilog/wiki/Structured-Data
From this:
{ "Fruit": ["Apple", "Pear", "Orange"] }
To this:
{
"Fruit": [
"Apple",
"Pear",
"Orange"
]
}
Edit:
Currently I'm using JsonConvert.SerializeObject({...}, Formatting.Indented)
but I'd like to move away from this for reasons like proper coloring from the console package, faster serialization, deferred serialization etc.
I seem to recall that we had to do a custom formatter at work a few years ago to modify the default json output from serilog. I do not remember the exact problem we had.
You could take a look at, https://github.com/serilog/serilog/wiki/Formatting-Output, if you haven't already
I have started using https://getseq.net/ to look at the structured output during development, I would highly recommend it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With