7

I am making a logger for a c# application which needs to log the time when each method was called each method's execution time.

I can do this by calling my own EventLogger.LogMethodCall method at the start of every method, but I was wondering if there was a way to make the CLR fire an event every time a new method is called so I wouldn't have to manually call my method.

Thanks.

Akram Shahda
  • 14,655
  • 4
  • 45
  • 65
Petkovsky
  • 134
  • 2
  • 6

3 Answers3

4

Try to look into PostSharp and Aspect Oriented Programming

cwap
  • 11,087
  • 8
  • 47
  • 61
1

Perhaps you should use a profiler to get the information you need?

Dutch Nico
  • 250
  • 2
  • 8
0

I don't believe that can be done. Rather than write your own logger, may I recommend Log4Net?

Richard Brightwell
  • 3,012
  • 2
  • 20
  • 22