destructurama / attributed

Use attributes to control how complex types are logged to Serilog.
Apache License 2.0
269 stars 33 forks source link

DestructureObjects = true Not Working #47

Closed bsulliva closed 1 year ago

bsulliva commented 4 years ago

Hello, I'm using this github package, serilog-timings, and destructurama.attributed. I've found that when I set destructureObjects to true in the following code, op.Complete("Result", response, true);, it does not enforce the Destructure.MaxDepth and Destrcuture.UsingAttributes. It is only being enforced in the message template when I use the @ operator. I've also seen when using .ForContext(), its the same thing, log.ForContext("RequestBody", request, true).

Is it possible to apply destructuring rules to both?

SimonCropp commented 3 years ago

can you share a failing unit test as a pull request

sungam3r commented 3 years ago

It is only being enforced in the message template when I use the @ operator.

I think that this is the right behavior. Otherwise ToString() is used without traversing object structure. See https://github.com/serilog/serilog/wiki/Structured-Data#objects :

When Serilog doesn't recognise the type, and no operator is specified (see below) then the object will be rendered using ToString().

And https://github.com/serilog/serilog/wiki/Structured-Data#preserving-object-structure .