Re: logging from a helper

"Michael Nash JGlobal.com" <[email protected]> Mon, 3 May 2004 14:50:04 -0400
Newsgroups gmane.comp.java.keel.user
Organization JGlobal
Message-ID <20040503145004.6397482a@jglobal>
Gene:

In the code below, I think the problem is that a Helper is not a "component" from Avalon/Keel's point of view. Therefore even though it might implement the lifecycle interface (enableLogging), the method won't get called, as the class is instantiated from a Persistent, not by the Container itself.

Passing the log from the Persistent or the PersistentFactory would probably be the way to go - I'll have a look at the code and see where this could easily be done.

Mike

On Mon, 03 May 2004 10:20:57 -0500
Gene McCullough <[email protected]> wrote:

> I've tried this, without success.  Maybe you can see where i went
> astray.
> 
> I've created a HelperBase that extends AbstractHelper, and added
> logging:
> 
> <snip>
> ...
> import org.apache.avalon.framework.logger.LogEnabled;
> import org.apache.avalon.framework.logger.Logger;
> ...
> public class HelperBase extends AbstractHelper implements LogEnabled  {
> 	
> 	protected Logger log = null;
> 
>    /**
>      * @see
> org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
>      */
>     public void enableLogging(Logger logger) {
>         log = logger;
>     }
> ...
> }
> 
> <snip/>
> 
> then, my helper has:
> 
> <snip>
> 
> public class MyHelper extends HelperBase {
> 
> 	public void testLogging(){
> 		//if(log.isDebugEnabled())
> 			log.info("It worked!");
> 	}
> ...
> }
> <snip/>
> 
> 
> I get a NPE exception when trying to execute testLogging from my model.
> I'm thinking at this point I haven't got the logkit (which is what I'm
> using since it is default) configured properly, but I'm not sure what I
> need to add where.
> 
> thanks again
> gene
> 
> On Tue, 2004-04-27 at 13:41, gene wrote:
> > Is there an easy way for my helper class to log to the persistent
> > logger?
> > 
> > TIA
> > gene
> > 
> > _______________________________________________
> > User mailing list
> > [email protected]
> > http://lists.keelframework.org/listinfo.cgi/user-keelframework.org
> 
> _______________________________________________
> User mailing list
> [email protected]
> http://lists.keelframework.org/listinfo.cgi/user-keelframework.org


-- 
Michael Nash

JGlobal Ltd 
Next-Generation Web Application Development and Open Source Support
http://www.jglobal.com

Bahamas Commerce and Trade
Offshore eCommerce Hosting and Business Services
http://www.bahamascommerce.com