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
This commit is contained in:
@@ -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 $
|
* $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.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2002/02/14 00:19:03 $
|
* $Date: 2002/02/14 03:48:44 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -82,7 +82,7 @@ import java.util.Properties;
|
|||||||
*
|
*
|
||||||
* @author Craig R. McClanahan
|
* @author Craig R. McClanahan
|
||||||
* @author Costin Manolache
|
* @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 {
|
public abstract class LogFactory {
|
||||||
@@ -276,14 +276,15 @@ public abstract class LogFactory {
|
|||||||
props.load(stream);
|
props.load(stream);
|
||||||
stream.close();
|
stream.close();
|
||||||
String factoryClass = props.getProperty(FACTORY_PROPERTY);
|
String factoryClass = props.getProperty(FACTORY_PROPERTY);
|
||||||
if (factoryClass != null) {
|
if (factoryClass == null) {
|
||||||
factory = newFactory(factoryClass, classLoader);
|
factoryClass = FACTORY_DEFAULT;
|
||||||
Enumeration names = props.propertyNames();
|
}
|
||||||
while (names.hasMoreElements()) {
|
factory = newFactory(factoryClass, classLoader);
|
||||||
String name = (String) names.nextElement();
|
Enumeration names = props.propertyNames();
|
||||||
String value = props.getProperty(name);
|
while (names.hasMoreElements()) {
|
||||||
factory.setAttribute(name, value);
|
String name = (String) names.nextElement();
|
||||||
}
|
String value = props.getProperty(name);
|
||||||
|
factory.setAttribute(name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -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 $
|
* $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.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2002/02/14 00:19:03 $
|
* $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
|
* following algorithm to dynamically select a logging implementation
|
||||||
* class to instantiate a wrapper for:</p>
|
* class to instantiate a wrapper for:</p>
|
||||||
* <ul>
|
* <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
|
* <li>Use the <code>org.apache.commons.logging.Log</code> system property
|
||||||
* to identify the requested implementation class.</li>
|
* to identify the requested implementation class.</li>
|
||||||
* <li>If <em>Log4J</em> is available, return an instance of
|
* <li>If <em>Log4J</em> is available, return an instance of
|
||||||
@@ -101,7 +104,7 @@ import org.apache.commons.logging.LogSource;
|
|||||||
*
|
*
|
||||||
* @author Rod Waldhoff
|
* @author Rod Waldhoff
|
||||||
* @author Craig R. McClanahan
|
* @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 {
|
public class LogFactoryImpl extends LogFactory {
|
||||||
@@ -127,7 +130,7 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
* The fully qualified name of the default {@link Log} implementation.
|
* The fully qualified name of the default {@link Log} implementation.
|
||||||
*/
|
*/
|
||||||
public static final String LOG_DEFAULT =
|
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 {
|
throws LogConfigurationException {
|
||||||
|
|
||||||
Log instance = (Log) instances.get(name);
|
Log instance = (Log) instances.get(name);
|
||||||
if (instance != null) {
|
if (instance == null) {
|
||||||
instance = newInstance(name);
|
instance = newInstance(name);
|
||||||
instances.put(name, instance);
|
instances.put(name, instance);
|
||||||
}
|
}
|
||||||
@@ -348,7 +351,13 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
// Identify the Log implementation class we will be using
|
// Identify the Log implementation class we will be using
|
||||||
String logClassName = null;
|
String logClassName = null;
|
||||||
try {
|
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
|
if (logClassName == null) { // @deprecated
|
||||||
logClassName = System.getProperty(LOG_PROPERTY_OLD);
|
logClassName = System.getProperty(LOG_PROPERTY_OLD);
|
||||||
}
|
}
|
||||||
@@ -361,8 +370,7 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
"org.apache.commons.logging.impl.Jdk14Logger";
|
"org.apache.commons.logging.impl.Jdk14Logger";
|
||||||
}
|
}
|
||||||
if (logClassName == null) {
|
if (logClassName == null) {
|
||||||
logClassName =
|
logClassName = LOG_DEFAULT;
|
||||||
"org.apache.commons.logging.impl.NoOpLog";
|
|
||||||
}
|
}
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user