tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Herrmann <...@jadn.com>
Subject Re: [5] commons-logging
Date Tue, 06 Aug 2002 17:13:54 GMT
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