Serilog.Sinks.Logz.Io
Serilog.Sinks.Logz.Io copied to clipboard
Writing context object as JSON object rather than flattened fields
I would like to log additional structured content that complements the logged message like this:
Logger
.ForContext("payload", new {FooBar = "xxx", BarFoo = "yyy"}, true)
.Warning("hello world");
This gives me some JSON similar to this with flattened properties and wrong casing:
{
"message": "hello world",
"level": "warning",
...
"payload.FooBar": "xxx",
"payload.BarFoo": "yyy"
}
Is there a setting or an easy way to override a formatter in order to have the payload logged like this (object with camel casing like the rest)?
{
"message": "hello world",
"level": "warning",
...
"payload": {
"fooBar": "xxx",
"barFoo": "yyy"
}
}
Thanks for your advice :)