You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Bob Herrmann <bo...@jadn.com> on 2002/08/06 19:13:54 UTC

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

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [5] commons-logging

Posted by Remy Maucherat <re...@apache.org>.
Costin Manolache wrote:
> 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.

I agree with that. It will take more time and effort, but it is cleaner. 
Since we are doing a major release and I don't really care about 
schedule anymore (only about putting something good out), I think we 
should rearchitect a bit.

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

+1 on deprecating (or worse; I'd advocate removing it, actually) debug, BTW.

Remy


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


Re: [5] commons-logging

Posted by Costin Manolache <cm...@yahoo.com>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [5] commons-logging

Posted by co...@covalent.net.
On Tue, 6 Aug 2002, Craig R. McClanahan wrote:

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

My thinking was that ServletContext.log will be 'routed' through 
commons-logging as well - and share the same logger configurability
and features as the rest of tomcat.

In other words the format, appender, output file will be configurable,
we'll get the ability to log the method/class that called 
ServletContext.log(), etc.

My only problem with using <Logger> is that it complicates things 
and it's hard to keep it at the same feature-level with 'real'
loggers like log4j or the jdk1.4 logger. 

For now I won't touch ServletContext.log - only implementation 
classes and the internal 'log'.

Costin


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


Re: [5] commons-logging

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On 6 Aug 2002, Bob Herrmann wrote:

> Date: 06 Aug 2002 13:13:54 -0400
> From: Bob Herrmann <bo...@jadn.com>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: Tomcat Developers List <to...@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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>