Is there a way in Log4Net or NLog (or some other logger) to output logs in an execution-stack-nested XML or JSON format, such that if function A()
calls B(7)
that calls C("something")
, it'll output something like:
<Method name="A">
<Method name="B" params="(int) 7">
<Method name="C" params="(string) 'something'"/>
</Method>
</Method>
or even better:
<Method name="A">
<Method name="B" params="(int) 7">
<Params>
<int>7</int>
</Params>
<Method name="C">
<Params>
<string>something</string>
</Params>
</Method>
</Method>
</Method>
Why? so I'd be able to use (e.g.) XML Notepad or some JSON
-viewer (don't know of any remarkable one...) to quickly fold (irrelevant) or unfold (relevant) sub-calls when trying to understand what went wrong. I use PostSharp
to log (currently using mere indentation) every method entry/exit and exceptions