views:

43

answers:

2

Hi, I'm using log4net in my application (.net 4 framework). is there any way to configure it in shuch way that every function call will be logged (without adding manually logging call in the begining of the function) Thanks.

+2  A: 

Sounds like you may want to investigate aspect-oriented-programming. See here for details on Aspect.net.

The general approach would be to write an aspect to provide code at the start/end of a function, and to specify what to do in this situation (in your case, log something). The aspect is weaved into your code during the build process, but your source code remains untouched by all the extra logging.

Brian Agnew
A: 

Log4PostSharp would do what you want but it is not yet available for .Net 4.0. Maybe it is worth to try it out...

Stefan Egli