You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by David <ac...@yahoo.es> on 2006/04/06 11:47:05 UTC

logging: How to configure programatically for using java.util.logging

Dear members,
   
  I would like to use java.util.logging and configure it programatically, on the common-logging documentation there is information about how to do it with the properties files, but I don't see the way for doing directly on the source code.
   
  I have a simple class that have setLogger/getLogger, I just wanto to test in a tester class how should work for using java.util.loggins or the Simple log from commons.
   
  That's all, thanks in advance,
   
  David

		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.

Re: logging: How to configure programatically for using java.util.logging

Posted by David <ac...@yahoo.es>.
Thanks Boris,
   
  that if was looking for,
   
  David

Boris Unckel <bo...@gmx.net> wrote:
  Hello,

by mistake I responded directly to Simon and not the list.
Here my remark and his answer.

Regards
Boris

Von: Simon Kitching 
On Thu, 2006-04-06 at 12:05 +0200, Boris Unckel wrote:
> Hello,
> > Von: Simon Kitching 
> > On Thu, 2006-04-06 at 02:47 -0700, David wrote:
> > > Dear members,
> > > 
> > > I would like to use java.util.logging and configure it
> > > programatically, on the common-logging documentation there is 
> > > information about how to do
> > > it with the properties files, but I don't see the way for doing 
> > > directly on the source code.
> > >
> > > I have a simple class that have setLogger/getLogger, I just wanto to
> > > test in a tester class how should work for using java.util.loggins or 
> > >the Simple log from commons.
> > commons-logging does not provide *any* mechanism for configuring the
> > "real" underlying logging library (except for the special case of the
> There is a small misunderstanding:
> As I understand, he wants to know how to configure commons-logging not by
> property but by code. He is not interested in a "configure-the-underlying"
> method.

Ah, you might be right..

> As I currently know, there is no method available to choose the
> underlying-API from user code. You would have to provide your own
> implementation of the discovery and factory mechanism.

There *is* such a mechanism. This call:
LogFactory.getFactory().setAttribute(
"org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.JDK14Log");
will force the use of java.util.logging.

Of course it needs to be called before any Log instances are created...

Cheers,

Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org



		
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

Re: logging: How to configure programatically for using java.util.logging

Posted by Boris Unckel <bo...@gmx.net>.
Hello,

by mistake I responded directly to Simon and not the list.
Here my remark and his answer.

Regards
Boris

Von: Simon Kitching <sk...@apache.org>
On Thu, 2006-04-06 at 12:05 +0200, Boris Unckel wrote:
> Hello,
> > Von: Simon Kitching <sk...@apache.org>
> > On Thu, 2006-04-06 at 02:47 -0700, David wrote:
> > > Dear members,
> > >    
> > > I would like to use java.util.logging and configure it
> > > programatically, on the common-logging documentation there is 
> > > information about how to do
> > > it with the properties files, but I don't see the way for doing 
> > > directly on the source code.
> > >
> > > I have a simple class that have setLogger/getLogger, I just wanto to
> > > test in a tester class how should work for using java.util.loggins or 
> > >the Simple log from commons.
> > commons-logging does not provide *any* mechanism for configuring the
> > "real" underlying logging library (except for the special case of the
> There is a small misunderstanding:
> As I understand, he wants to know how to configure commons-logging not by
> property but by code. He is not interested in a "configure-the-underlying"
> method.

Ah, you might be right..

> As I currently know, there is no method available to choose the
> underlying-API from user code. You would have to provide your own
> implementation of the discovery and factory mechanism.

There *is* such a mechanism. This call:
  LogFactory.getFactory().setAttribute(
	"org.apache.commons.logging.Log",
        "org.apache.commons.logging.impl.JDK14Log");
will force the use of java.util.logging.

Of course it needs to be called before any Log instances are created...

Cheers,

Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: logging: How to configure programatically for using java.util.logging

Posted by Simon Kitching <sk...@apache.org>.
On Thu, 2006-04-06 at 02:47 -0700, David wrote:
> Dear members,
>    
>   I would like to use java.util.logging and configure it programatically, on the common-logging documentation there is information about how to do it with the properties files, but I don't see the way for doing directly on the source code.
>    
>   I have a simple class that have setLogger/getLogger, I just wanto to test in a tester class how should work for using java.util.loggins or the Simple log from commons.
>    
>   That's all, thanks in advance,

commons-logging does not provide *any* mechanism for configuring the
"real" underlying logging library (except for the special case of the
built-in simple-log implementation). Commons-logging just forwards
messages to some other library which is assumed to be configured already
(or capable of configuring itself somehow).

The only configuration supported by commons-logging is to (optionally)
tell it which underlying library it should bind to.

The information in the docs about how to configure java.util.logging is
just there to help people new to logging; it isn't part of the
commons-logging functionality.

To configure java.util.logging, you need to use java.util.logging
methods.

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org