c# - How to trace every method called -
c# - How to trace every method called -
i have existing project find out calls beingness made , maybe dump log file.
i had at thread, didnt help much. tried postsharp, , illustration shows how accomplish it. need add together attribute every darn method. beingness existing project, in-numerous methods not feasible option.
is there other means can trace calls made?
use profiler in tracing mode. see how phone call each other , time spent. besides commercial profilers there free ones. managed code there np profiler quite good.
if want go deeper can utilize windows performance toolkit gives total info accross threads , how interact each other if want know. difference stacks ranging kernel until managed frames.
if not plenty can instrument code tracing library (either automatically postsharp, ....) or manually or macro each source file. have made little tracing library quite fast , highly configurable. see here. unique feature can trace thrown exception automatically.
private void someothermethod() { using (tracer t = new tracer(mytype, "someothermethod")) { faultymethod(); } } private void faultymethod() { throw new notimplementedexception("hi fault"); }
here comes output:
18:57:46.665 03064/05180 <{{ > apichange.integrationtests.diagnostics.tracingtests.somemethod 18:57:46.668 03064/05180 <{{ > apichange.integrationtests.diagnostics.tracingtests.someothermethod 18:57:46.670 03064/05180 < }}< apichange.integrationtests.diagnostics.tracingtests.someothermethod exception thrown: system.notimplementedexception: hi fault @ apichange.integrationtests.diagnostics.tracingtests.faultymethod() @ apichange.integrationtests.diagnostics.tracingtests.someothermethod() @ apichange.integrationtests.diagnostics.tracingtests.somemethod() @ apichange.integrationtests.diagnostics.tracingtests.demo_show_leaving_trace_with_exception() 18:57:46.670 03064/05180 < }}< apichange.integrationtests.diagnostics.tracingtests.someothermethod duration 2ms 18:57:46.689 03064/05180 < }}< apichange.integrationtests.diagnostics.tracingtests.somemethod duration 24ms
c# logging trace
Comments
Post a Comment