At this time all objects are destructured with the same depth as assigned by .Destructure.ToMaximumDepth(depth)
. It would be useful to set the destructuring depth per object using either .Destructure.ToMaximumDepth(type, depth)
or possibly by using {@Object:depth}
format. Ex:
Option 1:
var log = new LoggerConfiguration()
.Destructure.ToMaximumDepth(typeof(System.Threading.Thread),2);
.CreateLogger();
Option 2:
var thread = .... // a thread
Log.Information("Started thread {@Thread:2}.", thread);
Thank you.
Thanks for the issue; I like both of these and if we're going to consider the feature it probably makes sense to offer both versions.
I'm unsure how much internal churn this would cause - there's probably a good amount of work involved in analyzing the possible implementations for the change, so any input in that direction would be appreciated.
(CC @adamchester who may find this interesting WRT the independent _message templates_ implementation he's created.)
Yes, I do find this suggestion interesting, and it seems useful to me (especially if you are logging types like Thread
).
i think depth
is better represented in the template with some other format / character ( not :
).
While this is still an interesting feature opportunity to pursue I can't see it reaching the top of the priority list in the near future, so I'm tempted to close it and unclutter the tracker. Any thoughts?
Agree @nblumhardt
I think it's currently best if users project/transform Thread
(or similar) into some type better suited to logging serialisation.