Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
How to log all frames in a call stack for a console based application?

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

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
Updated 8-Sep-12 8:17am
v2

1 solution

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. !

Regards,

— Manfred
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900