Closed bowdens07 closed 8 months ago
This issue was marked as stale since it has not been active for a long time
This issue was marked as stale since it has not been active for a long time
While this is likely intended behavior
I don't think so. I added destructureObjects: true
in #110 and test.
Suppose I'm logging a class that has another class inside of it, like so:
So we see MessageBase has a ContextClass inside of it. If I add the [LogWithName()] attribute over the Context property in MessageBase, serilog will no longer destructure MessageBase's Context property in the output, and will simply output Context's ToString() method. So here's the difference in output:
Without [LogWithName("messageContext")] on MessageBase's Context Property:
{"ContextClass": {"foo":"", "bar":""}}
With [LogWithName("messageContext")] on MessageBase's Context Property:
{"messageContext":"ContextClass ToString Output" }
While this is likely intended behavior, I would like some way to destructure the properties that use the [LogWithName()]. Ideally, I'd like a way for my output to be this:
{"messageContext": {"foo":"", "bar":""}}
Perhaps an argument like a boolean could be passed to the [LogWithName()] attribute, so its API would now be
[LogWithName(string newName, bool destructureObjects=false)]
Note - I am using Serilog.Formatting.Compact.CompactJsonFormatter going into a Console sink, although I don't think that changes the spirit of my question minus some minor details on precisely what the output format looks like. I'm just concerned with destructuring every property that uses destructurama attributes in my output.
Thank you for your time.