tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: [5] commons-logging
Date Tue, 06 Aug 2002 17:45:21 GMT


On 6 Aug 2002, Bob Herrmann wrote:

> Date: 06 Aug 2002 13:13:54 -0400
> From: Bob Herrmann <bob@jadn.com>
> Reply-To: Tomcat Developers List <tomcat-dev@jakarta.apache.org>
> To: Tomcat Developers List <tomcat-dev@jakarta.apache.org>
> Subject: Re: [5] commons-logging
>
> 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.)
>

I think backwards compatibility for the output of ServletContext.log()
method calls (which ultimately get routed to the <Logger> associated with
the Context) would be nice, but not necessarily mission critical.  I think
we should feel free to re-architect how Catalina internal components do
their logging (i.e. switch to commons-logging and not go through the
Logger mechanism).

> 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);
>         }
>     }
>

Based on my philosophy statement above, I'd dispense with all the private
log() methods and just use commons-logging APIs directly -- with the
exception of the implementation of ServletContext.log() calls.

> Cheers,
> -bob

Craig


--
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