Re: [SUMMARY] How can I log in non-Cocoon Java classes? -- Improved solution

2002-09-13 Thread Alan Hodgkinson


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]




RE: [SUMMARY] How can I log in non-Cocoon Java classes? -- Improved solution

2002-09-13 Thread Piroumian Konstantin

 From: Alan Hodgkinson [mailto:[EMAIL PROTECTED]] 
 Dear Piroumian,

I'd say: 'Dear Konstantin'.
(Reminder to myself: Create a FAQ entry for the name format of our Exchange
server ;)).

 
   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. :)

It's not a different technic, cause the AbstractLogEnabled simply implements
the LogEnabled interface and provide a pair of convenience methods.

 I just tried it your technique and it works just fine.

[...]

 
 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.

That's why I like the Wiki: it's extremely easy to update.

Btw, there is a cocoon-docs mail list where Cocoon documentation discussions
take place, so maybe you'll like to join the list.

Regards,
  person
titleMr/title
firstnameKonstantin/firstname
lastnamePiroumian/lastname
  /person


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]