org.apache.commons.logging
public class LogSource extends Object
Deprecated: Use {@link LogFactory} instead - The default factory implementation performs exactly the same algorithm as this class did
Factory for creating {@link Log} instances. Applications should call
the makeNewLogInstance()
method to instantiate new instances
of the configured {@link Log} implementation class.
By default, calling getInstance()
will use the following
algorithm:
org.apache.commons.logging.impl.Log4JLogger
.org.apache.commons.logging.impl.Jdk14Logger
.org.apache.commons.logging.impl.NoOpLog
.You can change the default behavior in one of two ways:
org.apache.commons.logging.log
to the name of the
org.apache.commons.logging.Log
implementation class
you want to use.LogSource.setLogImplementation()
.Version: $Id: LogSource.java,v 1.21 2004/02/28 21:46:45 craigmcc Exp $
Field Summary | |
---|---|
protected static boolean | jdk14IsAvailable Is JDK 1.4 logging available |
protected static boolean | log4jIsAvailable Is log4j available (in the current classpath) |
protected static Constructor | logImplctor Constructor for current log class |
protected static Hashtable | logs |
Constructor Summary | |
---|---|
LogSource() Don't allow others to create instances |
Method Summary | |
---|---|
static Log | getInstance(String name) Get a Log instance by class name |
static Log | getInstance(Class clazz) Get a Log instance by class |
static String[] | getLogNames()
Returns a {@link String} array containing the names of
all logs known to me. |
static Log | makeNewLogInstance(String name)
Create a new {@link Log} implementation, based
on the given name.
|
static void | setLogImplementation(String classname)
Set the log implementation/log implementation factory
by the name of the class. |
static void | setLogImplementation(Class logclass)
Set the log implementation/log implementation factory
by class. |
Log
instance by class nameLog
instance by classThe specific {@link Log} implementation returned is determined by the value of the org.apache.commons.logging.log property. The value of org.apache.commons.logging.log may be set to the fully specified name of a class that implements the {@link Log} interface. This class must also have a public constructor that takes a single {@link String} argument (containing the name of the {@link Log} to be constructed.
When org.apache.commons.logging.log is not set, or when no corresponding class can be found, this method will return a Log4JLogger if the log4j Logger class is available in the {@link LogSource}'s classpath, or a Jdk14Logger if we are on a JDK 1.4 or later system, or NoOpLog if neither of the above conditions is true.
Parameters: name the log name (or category)