craigmcc 02/02/13 19:48:44
Modified: logging/src/java/org/apache/commons/logging LogFactory.java
logging/src/java/org/apache/commons/logging/impl
LogFactoryImpl.java
Log:
Fix the implementation in LogFactory and LogFactoryImpl so that it actually
works as documented.
Revision Changes Path
1.3 +13 -12
jakarta-commons/logging/src/java/org/apache/commons/logging/LogFactory.java
Index: LogFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LogFactory.java 14 Feb 2002 00:19:03 -0000 1.2
+++ LogFactory.java 14 Feb 2002 03:48:44 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogFactory.java,v
1.2 2002/02/14 00:19:03 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2002/02/14 00:19:03 $
+ * $Header:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/LogFactory.java,v
1.3 2002/02/14 03:48:44 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/02/14 03:48:44 $
*
* ====================================================================
*
@@ -82,7 +82,7 @@
*
* @author Craig R. McClanahan
* @author Costin Manolache
- * @version $Revision: 1.2 $ $Date: 2002/02/14 00:19:03 $
+ * @version $Revision: 1.3 $ $Date: 2002/02/14 03:48:44 $
*/
public abstract class LogFactory {
@@ -276,14 +276,15 @@
props.load(stream);
stream.close();
String factoryClass = props.getProperty(FACTORY_PROPERTY);
- if (factoryClass != null) {
- factory = newFactory(factoryClass, classLoader);
- Enumeration names = props.propertyNames();
- while (names.hasMoreElements()) {
- String name = (String) names.nextElement();
- String value = props.getProperty(name);
- factory.setAttribute(name, value);
- }
+ if (factoryClass == null) {
+ factoryClass = FACTORY_DEFAULT;
+ }
+ factory = newFactory(factoryClass, classLoader);
+ Enumeration names = props.propertyNames();
+ while (names.hasMoreElements()) {
+ String name = (String) names.nextElement();
+ String value = props.getProperty(name);
+ factory.setAttribute(name, value);
}
}
} catch (IOException e) {
1.3 +17 -9
jakarta-commons/logging/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
Index: LogFactoryImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LogFactoryImpl.java 14 Feb 2002 00:19:03 -0000 1.2
+++ LogFactoryImpl.java 14 Feb 2002 03:48:44 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java,v
1.2 2002/02/14 00:19:03 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2002/02/14 00:19:03 $
+ * $Header:
/home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java,v
1.3 2002/02/14 03:48:44 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/02/14 03:48:44 $
*
* ====================================================================
*
@@ -78,6 +78,9 @@
* following algorithm to dynamically select a logging implementation
* class to instantiate a wrapper for:</p>
* <ul>
+ * <li>Use a factory configuration attribute named
+ * <code>org.apache.commons.logging.Log</code> to identify the
+ * requested implementation class.</li>
* <li>Use the <code>org.apache.commons.logging.Log</code> system property
* to identify the requested implementation class.</li>
* <li>If <em>Log4J</em> is available, return an instance of
@@ -101,7 +104,7 @@
*
* @author Rod Waldhoff
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2002/02/14 00:19:03 $
+ * @version $Revision: 1.3 $ $Date: 2002/02/14 03:48:44 $
*/
public class LogFactoryImpl extends LogFactory {
@@ -127,7 +130,7 @@
* The fully qualified name of the default {@link Log} implementation.
*/
public static final String LOG_DEFAULT =
- "org.apache.commons.logging.NoOpLog";
+ "org.apache.commons.logging.impl.NoOpLog";
/**
@@ -266,7 +269,7 @@
throws LogConfigurationException {
Log instance = (Log) instances.get(name);
- if (instance != null) {
+ if (instance == null) {
instance = newInstance(name);
instances.put(name, instance);
}
@@ -348,7 +351,13 @@
// Identify the Log implementation class we will be using
String logClassName = null;
try {
- logClassName = System.getProperty(LOG_PROPERTY);
+ logClassName = (String) getAttribute(LOG_PROPERTY);
+ if (logClassName == null) { // @deprecated
+ logClassName = (String) getAttribute(LOG_PROPERTY_OLD);
+ }
+ if (logClassName == null) {
+ logClassName = System.getProperty(LOG_PROPERTY);
+ }
if (logClassName == null) { // @deprecated
logClassName = System.getProperty(LOG_PROPERTY_OLD);
}
@@ -361,8 +370,7 @@
"org.apache.commons.logging.impl.Jdk14Logger";
}
if (logClassName == null) {
- logClassName =
- "org.apache.commons.logging.impl.NoOpLog";
+ logClassName = LOG_DEFAULT;
}
} catch (SecurityException e) {
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>