From 87cfde50b68929ca94e29e64ea138d29123b639f Mon Sep 17 00:00:00 2001
From: "Craig R. McClanahan"
Date: Thu, 14 Feb 2002 03:48:44 +0000
Subject: [PATCH] Fix the implementation in LogFactory and LogFactoryImpl so
that it actually works as documented.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138859 13f79535-47bb-0310-9956-ffa450edef68
---
.../apache/commons/logging/LogFactory.java | 25 +++++++++---------
.../commons/logging/impl/LogFactoryImpl.java | 26 ++++++++++++-------
2 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/src/java/org/apache/commons/logging/LogFactory.java b/src/java/org/apache/commons/logging/LogFactory.java
index 14f63e4..5b9fdba 100644
--- a/src/java/org/apache/commons/logging/LogFactory.java
+++ b/src/java/org/apache/commons/logging/LogFactory.java
@@ -1,7 +1,7 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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/jerenkrantz/tmp/commons/commons-convert/cvs/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 @@ import java.util.Properties;
*
* @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 @@ public abstract class LogFactory {
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) {
diff --git a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
index 5440310..7949de4 100644
--- a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
+++ b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
@@ -1,7 +1,7 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/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/jerenkrantz/tmp/commons/commons-convert/cvs/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 @@ import org.apache.commons.logging.LogSource;
* following algorithm to dynamically select a logging implementation
* class to instantiate a wrapper for:
*
+ * - Use a factory configuration attribute named
+ *
org.apache.commons.logging.Log to identify the
+ * requested implementation class.
* - Use the
org.apache.commons.logging.Log system property
* to identify the requested implementation class.
* - If Log4J is available, return an instance of
@@ -101,7 +104,7 @@ import org.apache.commons.logging.LogSource;
*
* @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 @@ public class LogFactoryImpl extends LogFactory {
* 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 @@ public class LogFactoryImpl extends LogFactory {
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 @@ public class LogFactoryImpl extends LogFactory {
// 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 @@ public class LogFactoryImpl extends LogFactory {
"org.apache.commons.logging.impl.Jdk14Logger";
}
if (logClassName == null) {
- logClassName =
- "org.apache.commons.logging.impl.NoOpLog";
+ logClassName = LOG_DEFAULT;
}
} catch (SecurityException e) {
}