You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Steve Loughran <st...@iseran.com> on 2003/01/18 09:19:42 UTC

commons logging q

so its pretty easy to do an implementation of the commons log that sends the
messages to ant at the appropriate level, but I am stuck at the factory

I need the current project (and preferably task) to set up the logger. I
suppose for custom tasks (like the Axis ones) we just choose and set up the
factory. But I know that the Axis code just calls LogFactory.getLog() ,
which retrieves a factory created by the standard commons algorithm, or that
set by the system properties (and hence created with an empty constructor).
And although the library caches the factory on a classloader by classloader
basis, there is no way to put a manually created factory into the cache.

The only way I can see that works is

(a) set some static prop in our logfactory impl to point to the current
project, maybe task
(b) set the system property org.apache.commons.logging.Log  to our class
(c) have the log factory get its data from the statics
(d) write something to hide (a) and (b) from the general public out of
embarassment.

Any other better solution out there?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: commons logging q

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Costin Manolache" <cm...@yahoo.com>
To: <an...@jakarta.apache.org>
Sent: Saturday, January 18, 2003 08:35
Subject: Re: commons logging q


> Steve Loughran wrote:
>
> > so its pretty easy to do an implementation of the commons log that sends
> > the messages to ant at the appropriate level, but I am stuck at the
> > factory
> >

> Not sure what you need - we can save the LogFactory in an ant reference,
> if you want all tasks to use the same factory.

no its more forcing some other code into using the factory we want them to.

>
> Or we can add a set method to c-l that sets the LogFactory for the current
> context. ( I don't think it should be the Thread, but the
> Thread.contextClassLoader() - so you can set it per webapp ).
>
> Something like
>  static LogFactory.setLogFactory( ClassLoader thCL, LogFactory f);
> Send a patch to commons, it seems a reasonable use case.

yes, that is what I am thinking would be the cleanest way.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: commons logging q

Posted by Costin Manolache <cm...@yahoo.com>.
Steve Loughran wrote:

> so its pretty easy to do an implementation of the commons log that sends
> the messages to ant at the appropriate level, but I am stuck at the
> factory
> 
> I need the current project (and preferably task) to set up the logger. I
> suppose for custom tasks (like the Axis ones) we just choose and set up
> the factory. But I know that the Axis code just calls LogFactory.getLog()
> , which retrieves a factory created by the standard commons algorithm, or
> that set by the system properties (and hence created with an empty
> constructor). And although the library caches the factory on a classloader
> by classloader basis, there is no way to put a manually created factory
> into the cache.
> 
> The only way I can see that works is
> 
> (a) set some static prop in our logfactory impl to point to the current
> project, maybe task
> (b) set the system property org.apache.commons.logging.Log  to our class
> (c) have the log factory get its data from the statics
> (d) write something to hide (a) and (b) from the general public out of
> embarassment.
> 
> Any other better solution out there?

Not sure what you need - we can save the LogFactory in an ant reference,
if you want all tasks to use the same factory.

Or we can add a set method to c-l that sets the LogFactory for the current
context. ( I don't think it should be the Thread, but the 
Thread.contextClassLoader() - so you can set it per webapp ). 

Something like 
 static LogFactory.setLogFactory( ClassLoader thCL, LogFactory f); 
Send a patch to commons, it seems a reasonable use case.

Costin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>