Class LogSource
- java.lang.Object
-
- org.apache.commons.logging.LogSource
-
@Deprecated public class LogSource extends java.lang.Object
Deprecated.UseLogFactory
instead - The default factory implementation performs exactly the same algorithm as this class didFactory for creatingLog
instances. Applications should call themakeNewLogInstance()
method to instantiate new instances of the configuredLog
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 theorg.apache.commons.logging.Log
implementation class you want to use. - At runtime, call
LogSource.setLogImplementation()
.
- If Log4J is available, return an instance of
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String[]
EMPTY_STRING_ARRAY
Deprecated.An empty immutableString
array.protected static boolean
jdk14IsAvailable
Deprecated.Is JDK 1.4 logging availableprotected static boolean
log4jIsAvailable
Deprecated.Is Log4j available (in the current classpath)protected static java.lang.reflect.Constructor<?>
logImplctor
Deprecated.Constructor for current log classprotected static java.util.Hashtable<java.lang.String,Log>
logs
Deprecated.Logs.
-
Constructor Summary
Constructors Modifier Constructor Description private
LogSource()
Deprecated.Don't allow others to create instances.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Log
getInstance(java.lang.Class<?> clazz)
Deprecated.Gets aLog
instance by class.static Log
getInstance(java.lang.String name)
Deprecated.Gets aLog
instance by class name.static java.lang.String[]
getLogNames()
Deprecated.Returns aString
array containing the names of all logs known to me.private static boolean
isClassForName(java.lang.String className)
Deprecated.static Log
makeNewLogInstance(java.lang.String name)
Deprecated.Create a newLog
implementation, based on the given name.static void
setLogImplementation(java.lang.Class<?> logClass)
Deprecated.Sets the log implementation/log implementation factory by class.static void
setLogImplementation(java.lang.String className)
Deprecated.Sets the log implementation/log implementation factory by the name of the class.
-
-
-
Field Detail
-
logs
protected static java.util.Hashtable<java.lang.String,Log> logs
Deprecated.Logs.
-
log4jIsAvailable
protected static boolean log4jIsAvailable
Deprecated.Is Log4j available (in the current classpath)
-
jdk14IsAvailable
protected static boolean jdk14IsAvailable
Deprecated.Is JDK 1.4 logging available
-
logImplctor
protected static java.lang.reflect.Constructor<?> logImplctor
Deprecated.Constructor for current log class
-
EMPTY_STRING_ARRAY
private static final java.lang.String[] EMPTY_STRING_ARRAY
Deprecated.An empty immutableString
array.
-
-
Method Detail
-
getInstance
public static Log getInstance(java.lang.Class<?> clazz)
Deprecated.Gets aLog
instance by class.- Parameters:
clazz
- a Class.- Returns:
- a
Log
instance.
-
getInstance
public static Log getInstance(java.lang.String name)
Deprecated.Gets aLog
instance by class name.- Parameters:
name
- Class name.- Returns:
- a
Log
instance.
-
getLogNames
public static java.lang.String[] getLogNames()
Deprecated.Returns aString
array containing the names of all logs known to me.- Returns:
- a
String
array containing the names of all logs known to me.
-
isClassForName
private static boolean isClassForName(java.lang.String className)
Deprecated.
-
makeNewLogInstance
public static Log makeNewLogInstance(java.lang.String name)
Deprecated.Create a newLog
implementation, based on the given name.The specific
Log
implementation returned is determined by the value of theorg.apache.commons.logging.log
property. The value oforg.apache.commons.logging.log
may be set to the fully specified name of a class that implements theLog
interface. This class must also have a public constructor that takes a singleString
argument (containing the name of theLog
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 theLogSource
'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)- Returns:
- a new instance.
-
setLogImplementation
public static void setLogImplementation(java.lang.Class<?> logClass) throws java.lang.LinkageError, java.lang.ExceptionInInitializerError, java.lang.NoSuchMethodException, java.lang.SecurityException
Deprecated.Sets the log implementation/log implementation factory by class. The given class must implementLog
, and provide a constructor that takes a singleString
argument (containing the name of the log).- Parameters:
logClass
- class.- Throws:
java.lang.LinkageError
- if there is missing dependency.java.lang.ExceptionInInitializerError
- unexpected exception has occurred in a static initializer.java.lang.NoSuchMethodException
- if a matching method is not found.java.lang.SecurityException
- If a security manager, s, is present and the caller's class loader is not the same as or an ancestor of the class loader for the current class and invocation ofs.checkPackageAccess()
denies access to the package of this class.
-
setLogImplementation
public static void setLogImplementation(java.lang.String className) throws java.lang.LinkageError, java.lang.SecurityException
Deprecated.Sets the log implementation/log implementation factory by the name of the class. The given class must implementLog
, and provide a constructor that takes a singleString
argument (containing the name of the log).- Parameters:
className
- class name.- Throws:
java.lang.LinkageError
- if there is missing dependency.java.lang.SecurityException
- If a security manager, s, is present and the caller's class loader is not the same as or an ancestor of the class loader for the current class and invocation ofs.checkPackageAccess()
denies access to the package of this class.
-
-