Dear Piroumian,
> > This explaines how to implement Cocoon-style logging, in a > > <snip/> > > 1. The class must extend AbstractLogEnabled. > > ..Isn't it enough to implement the LogEnabled interface? > <snip/> and provide methods for getting the logger? Yup, in Cocoon/Avalon, like Perl, there's more than one way to do it. :) I just tried it your technique and it works just fine. > The AbstractLogEnabled is a utility helper class and the problem with it is > that you'll have to extend it, which is not possible in all the cases, e.g. > if your class extends some app-specific base class and you can't change it. This is, in fact, a more flexible solution. In my simple case, I just needed logging from a bean and the extend was possible. With your method, you're free from the restriction. You do have the (minimal) overhead of implementing the LogEnabled interface, but in exchange you get the flexibility of not having to extend any log related classes. For the record, here's a summary of the improved solution: import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.LogEnabled; class SomeBean extends SomeOtherBean implements LogEnabled { .. // The LogEnabled interface is one method: enableLogging private Logger logger; public void enableLogging( Logger logger ) { this.logger = logger; } // Example method that writes to the log public void setThing( String thing ) { logger.debug( "SomeBean: thing = " + thing ); ... } } Note that you still have to call enabledLogging() with a valid Logger, before you use write to the log, as I explained in original summary. BTW: By popular demand, I published my original summary in the Wiki. http://outerthought.net/wiki/Wiki.jsp?page=JavaLogging But due to your input, it's already out of date :). I'll update it. Thanks your help and.. Best wishes, Alan. --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>