Re: logging from a helper
Gene McCullough <[email protected]> Mon, 03 May 2004 13:50:00 -0500
| Newsgroups | gmane.comp.java.keel.user |
|---|---|
| Message-ID | <[email protected]> |
Your words describe my thoughts much better! that was the issue I thought was happening, but I'm very "green" to Avalon. This is nothing big, and I would much rather see the build changes stable! They sound very promising. I'd looked at trying to pass in the logger, and looks like it would have to be done in all the implementations at the getHelper method for DefaultPersistent. but again, i probably don't know what i'm talking about. Maybe I'll just add this as a feature request for the future, but thank you very much for looking at it. gene On Mon, 2004-05-03 at 13:50, Michael Nash JGlobal.com wrote: > 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 >