Click here to Skip to main content
12,884,287 members (30,136 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#3.0 C# C#4.0
How to log all frames in a call stack for a console based application?

I am aware of this code:
StackTrace stackTrace = new StackTrace(); // get call stack
StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames)

But I want to log all the methods that are being executed and log the start of the function and end of the function.

We have lots of files and methods and with a minimal change i wish to log the start & end of functions without touching the actual methods.

If we can write seperate interface and just a statement in the main function it would be of great help.

Any suggestions would be appreciated.
Posted 8-Sep-12 8:14am
Updated 8-Sep-12 8:17am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You should look into Aspect Oriented Programming (AOP). There's an implementation available in Spring.NET. Please google "Spring.NET AOP".
AOP lets you inject code into methods via configuration with before and after options etc. !


— Manfred

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170422.1 | Last Updated 8 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100