This was something that I looked at a long time ago, AOP and dynamic injection sounded like a great idea, however it performance impact is huge for simple method calls. There are some context boundaries where this works, i.e. remoting or database access, but it is not appropriate for normal method calls.
The approach that I thought had the most promise was to post-process the assembly. Essentially take the assembly decompile it to IL (which is straight forward), look for method or class attributes, inject the logging calls (as IL) into the assembly IL for each method entry and exit point, then reassemble the assembly from the modified IL. This means that you can on a per assembly basis add logging calls or remove all logging calls. I did not peruse this approach because I was able to do what I needed by writing a CLR profiler and using that to log method calls, parameters and results. Nicko > -----Original Message----- > From: Ayende Rahien [mailto:[EMAIL PROTECTED] > Sent: 26 September 2004 13:44 > To: 'Log4NET User'; [EMAIL PROTECTED] > Subject: RE: Anyone consdiering attributes? > > You can do it using ContextBoundObject and some context > settings, it's not very well known (at least that I've seen), > but it's possible. > If you want something like this, check out an Aspect Oriented > Programning (AOP) for dotNet, They should contain it already. > Be aware, currently, AFAIK, there is some performance hit > using this method, as always, measure and see if it's acceptable. > > ________________________________ > > From: Mario Gutierrez [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 23, 2004 7:12 PM > To: 'Log4NET User' > Subject: RE: Anyone consdiering attributes? > > The idea is to have attributes like LogEntry and LogExit that > automaticaly log the entry and exit of any method call. As I > read more about attributes, I'm not sure it's possible to do > this unless I build an entire framework to read these > attributes and act on them. Since there are dependency > injection frameworks, Spring and pico come to mind, I think > I'll use one of those instead and create interceptors. > > -----Original Message----- > From: Ayende Rahien [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 22, 2004 6:07 PM > To: 'Log4NET User'; [EMAIL PROTECTED] > Subject: RE: Anyone consdiering attributes? > What do you want to do with this? > > > > ________________________________ > > From: Mario Gutierrez [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 23, 2004 1:44 AM > To: 'Log4NET User' > Subject: Anyone consdiering attributes? > > If not, maybe I'll contribute if I can find a free weekend. > > [LogEntry(ifLevel=Debug)] > public void Foo() { > // ... > } > > .: mario gutierrez > >
