tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Costin Manolache <cmanola...@yahoo.com>
Subject Re: [5] commons-logging
Date Tue, 06 Aug 2002 17:15:39 GMT
Ok, it seems things are not very clear.

For tomcat5 I would like to just use commons-logging - in all log
statements. The old <logger> will be deprecated - the interface
will be there but the code will use commons-logging directly.

We can change the log() method to call commons-logging to speed
up the transition, but I think the pattern should be the normal
commons-logging one - with:
  if( log.isDebugEnabled() ) 
     log.debug();
used inside the code. 

That also means the 'debug' attribute is on components will be 
deprecated. 

The goal of this is to have a single logging API used in all the code
( including coyote, jk, jasper ), with consistent configuration and
behavior.

We can do less - i.e. just use commons-logging if no <logger> is 
available.
We can also port the Logger and Log implementations to work as 
'commons-logging' impl. 

Craig, Remy - and everyone else - please post your preference. 

Costin



Bob Herrmann wrote:

> On Tue, 2002-08-06 at 12:52, costinm@covalent.net wrote:
>> Just to make sure: is everyone ok with using commons-logging in 5.0 ?
>> 
>> I'm doing some changes and I'm replacing or adding log statements
>> using commons-logging.
>> 
>> Please send your -1 if you think this should be discussed more.
> 
> Are you changing the log() methods so that they use a "logger" if
> present, but otherwise use commons logging?  (I think preserving the
> backwards compatibility of using the <Logger> tags in server.xml, was
> where I thought things were left.)
> 
> In other words, in code like this;
> 
>     private void log(String message) {
>         Logger logger = null;
>         if (container != null)
>             logger = container.getLogger();
>         if (logger != null) {
>             logger.log(getName() + "[" + container.getName() + "]: "
>                        + message);
>         } else {
>             String containerName = null;
>             if (container != null)
>                 containerName = container.getName();
> 
>             System.out.println(getName() + "[" + containerName
>                                + "]: " + message);
>         }
>     }
> 
> Would your changes to logging look more like this ?? ( I am just
> changing the System.out calls to instead defer to a commons-logging
> logger. )
> 
>     private void log(String message) {
>         Logger logger = null;
> 
>         if (container != null)
>             logger = container.getLogger();
> 
>         if (logger != null) {
>             logger.log(getName() + "[" + container.getName() + "]: "
>                        + message);
>         } else {
>             String containerName = null;
>             if (container != null)
>                 containerName = container.getName();
> 
>                 //import org.apache.commons.logging.Log;
>                 //import org.apache.commons.logging.LogFactory;
> 
>                 Log log = LogFactory.getLog( containerName );
> 
>                 log.info( getName() + "[" + containerName
>                                + "]: " + message);
>         }
>     }
> 
> Cheers,
> -bob




--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message