| java.lang.Object org.apache.commons.logging.LogSource
LogSource | public class LogSource (Code) | | Factory for creating
Log instances. Applications should call
the makeNewLogInstance() method to instantiate new instances
of the configured
Log implementation class.
By default, calling getInstance() will use the following
algorithm:
- If Log4J is available, return an instance of
org.apache.commons.logging.impl.Log4JLogger .
- If JDK 1.4 or later is available, return an instance of
org.apache.commons.logging.impl.Jdk14Logger .
- Otherwise, return an instance of
org.apache.commons.logging.impl.NoOpLog .
You can change the default behavior in one of two ways:
- On the startup command line, set the system property
org.apache.commons.logging.log to the name of the
org.apache.commons.logging.Log implementation class
you want to use.
- At runtime, call
LogSource.setLogImplementation() .
LogFactory author: Rod Waldhoff version: $Id: LogSource.java 155426 2005-02-26 13:10:49Z dirkv $ |
Method Summary | |
public static Log | getInstance(String name) | public static Log | getInstance(Class clazz) | public static String[] | getLogNames() Returns a
String array containing the names of
all logs known to me. | public static Log | makeNewLogInstance(String name) Create a new
Log implementation, based
on the given name.
The specific
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
Log interface. | public static void | setLogImplementation(String classname) Set the log implementation/log implementation factory
by the name of the class. | public static void | setLogImplementation(Class logclass) Set the log implementation/log implementation factory
by class. |
jdk14IsAvailable | protected static boolean jdk14IsAvailable(Code) | | Is JDK 1.4 logging available
|
log4jIsAvailable | protected static boolean log4jIsAvailable(Code) | | Is log4j available (in the current classpath)
|
logImplctor | protected static Constructor logImplctor(Code) | | Constructor for current log class
|
getInstance | public static Log getInstance(String name)(Code) | | Get a Log instance by class name
|
getInstance | public static Log getInstance(Class clazz)(Code) | | Get a Log instance by class
|
getLogNames | public static String[] getLogNames()(Code) | | Returns a
String array containing the names of
all logs known to me.
|
makeNewLogInstance | public static Log makeNewLogInstance(String name)(Code) | | Create a new
Log implementation, based
on the given name.
The specific
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
Log interface. This class must also
have a public constructor that takes a single
String argument (containing the name
of the
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
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) |
|
|