db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/util/logging LoggingConfiguration.java
Date Sun, 06 Jun 2004 19:44:44 GMT
tomdz       2004/06/06 12:44:44

  Modified:    src/java/org/apache/ojb/broker/util/logging
                        LoggingConfiguration.java
  Log:
  PoorMansLoggerImpl is now fallback logger (instead of commons-logging)
  Removed dependecy of this class to commons-logging so that OJB can be used without actually
having the commons-logging jar in the classpath
  
  Revision  Changes    Path
  1.6       +21 -5     db-ojb/src/java/org/apache/ojb/broker/util/logging/LoggingConfiguration.java
  
  Index: LoggingConfiguration.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/logging/LoggingConfiguration.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LoggingConfiguration.java	1 Jun 2004 21:42:21 -0000	1.5
  +++ LoggingConfiguration.java	6 Jun 2004 19:44:44 -0000	1.6
  @@ -18,7 +18,6 @@
   import java.io.InputStream;
   import java.util.Properties;
   
  -import org.apache.commons.logging.LogFactory;
   import org.apache.ojb.broker.util.ClassHelper;
   import org.apache.ojb.broker.util.configuration.impl.ConfigurationAbstractImpl;
   
  @@ -30,6 +29,12 @@
    */
   public class LoggingConfiguration extends ConfigurationAbstractImpl
   {
  +    /** The commons-logging property denoting which log to use. This property
  +     *  is repeated here to avoid making this class dependent upon commons-logging */
  +    public static final String PROPERTY_COMMONS_LOGGING_LOG = "org.apache.commons.logging.Log";
  +    /** The commons-logging property denoting which log factory to use. This property
  +     *  is repeated here to avoid making this class dependent upon commons-logging */
  +    public static final String PROPERTY_COMMONS_LOGGING_LOGFACTORY = "org.apache.commons.logging.LogFactory";
       /** The property denoting the OJB logger class */
       public static final String PROPERTY_OJB_LOGGERCLASS      = "org.apache.ojb.broker.util.logging.Logger.class";
       /** The property denoting the config file for the OJB logger class */
  @@ -122,7 +127,8 @@
           else
           {
               // still no logger configured - lets check whether commons-logging is configured
  -            if (System.getProperty(LogFactory.FACTORY_PROPERTY) != null)
  +            if ((System.getProperty(PROPERTY_COMMONS_LOGGING_LOG) != null) ||
  +                (System.getProperty(PROPERTY_COMMONS_LOGGING_LOGFACTORY) != null))
               {
                   // yep, so use commons-logging
                   _loggerClass = CommonsLoggerImpl.class;
  @@ -141,8 +147,18 @@
                   {}
                   if (_loggerClass == null)
                   {
  -                    // no, so default to commons-logging
  -                    _loggerClass = CommonsLoggerImpl.class;
  +                    // or a commons-logging.properties file ?
  +                    try
  +                    {
  +                        contextLoader.getResourceAsStream("commons-logging.properties");
  +                        // yep, so use commons-logging
  +                        _loggerClass      = CommonsLoggerImpl.class;
  +                        _loggerConfigFile = "commons-logging.properties";
  +                    }
  +                    catch (Exception ex)
  +                    {}
  +                    // no, so default to poor man's logging
  +                    _loggerClass = PoorMansLoggerImpl.class;
                   }
               }
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message