log4j and it's siblings are really nice. Aaron Farr discusses a few problems with it and IoC (Inversion of Control) and references some other blogs & Avalon stuff. I haven't yet read the Patterns book, so I don't exactly know what IoC or a Monitor means. However the Avalon wiki page referenced from his post makes an interesting point that logs are often used as stringified callbacks. return values are useful too.
So here's my question: can we some use Aspect-oriented solution and reflection to automatically log all method calls and their return values? Perhaps with a (x)doclet to give some fine-grained control over the logging. 80% of my logging is for debugging to get a "trace" of the code execution without connecting a debugger. This could pretty much automate that.
Posted by Dave at April 20, 2004 06:17 PM | TrackBackWhat you ask here is very easy to do in AOP. No need for xdoclet even. As Avalon uses interfaces all over can log all component calls via an ASL licensed tool like DynAOP pretty easily.
Posted by: Brian McCallister at April 20, 2004 07:21 PMIoC stands for Inversion of Contol. You can start learning about it at Avalon (http://avalon.apache.org), Picocontainer (http://picocontainer.org), or ComponentPlanet.org (http://componentplanet.org). The basic idea is that a component gives control of its lifecycle and dependency management to a container.
Paul Hammant give a pretty good example of a Monitor in his blog.
Yes, you can use AOP to do this and many people do. It's mostly a preference choice between AOP and a monitor pattern. Both avoid the pitfalls of direct logging which Paul pointed out.
Posted by: jaaron at April 20, 2004 11:53 PM