cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Hodgkinson <>
Subject How can I log in non-Cocoon Java classes?
Date Wed, 11 Sep 2002 16:21:21 GMT

Dear All,

Can someone give me a hint on how to implement Cocoon logging
in Java classes that don't extend from the 'Abstract{Cocoon}
classes (I.e. AbstractAction, AbstractReader, etc.)?

For example, how would I implement logging in a really simple 
Java Bean, that otherwise wouldn't have to know anything about 

I had hoped that I could 'extend AbstractLogEnabled' and 'implement
LogEnabled' in my class. I've searched for clues in all the 
examples, but they always extend some Cocoon-specific class (that 
magically make the logging work).

My code is roughly the following:

  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.logger.LogEnabled;
  import org.apache.avalon.framework.logger.Logger;

  public class MyClass
      extends AbstractLogEnabled
      implements LogEnabled
    private Logger logger;
    public void enableLogging(Logger logger) {
      this.logger = logger;

    public void myMethod() {
      getLogger().debug( "msg.." ); // <-- getLogger() returns null!

The problem is that getLogger() always returns null. I suspect
that I need to implement some other interface too. 

Suggestions anyone?

Many thanks in advance,


P.S. Of course I looked in my new Carsten/Matthew 'Castle Book' 
(for want of a better name), where logging is also described.
Unfortunately the logging method it recommends seems to have 
been superceeded by the methods in the examples. It can get their
method to compile, but it suffers from the same 'null getLogger()'
probelm I described above.

P.P.S. BTW: Nice book. Nicely written. But pity the software didn't
hold still :)

Please check that your question  has not already been answered in the
FAQ before posting.     <>

To unsubscribe, e-mail:     <>
For additional commands, e-mail:   <>

View raw message