Class LogSource
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.logto the name of theorg.apache.commons.logging.Logimplementation class you want to use. - At runtime, call
LogSource.setLogImplementation().
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static booleanDeprecated.Java 8 is the baseline and includes JUL.protected static booleanDeprecated.Is Log4j available (in the current classpath)protected static Constructor<?> Deprecated.Constructor for current log classDeprecated.Logs. -
Method Summary
Modifier and TypeMethodDescriptionstatic LoggetInstance(Class<?> clazz) Deprecated.Gets aLoginstance by class.static LoggetInstance(String name) Deprecated.Gets aLoginstance by class name.static String[]Deprecated.Returns aStringarray containing the names of all logs known to me.static LogmakeNewLogInstance(String name) Deprecated.Create a newLogimplementation, based on the given name.static voidsetLogImplementation(Class<?> logClass) Deprecated.Sets the log implementation/log implementation factory by class.static voidsetLogImplementation(String className) Deprecated.Sets the log implementation/log implementation factory by the name of the class.
-
Field Details
-
logs
Deprecated.Logs. -
log4jIsAvailable
Deprecated.Is Log4j available (in the current classpath) -
jdk14IsAvailable
Deprecated.Java 8 is the baseline and includes JUL.Is JDK 1.4 logging available, always true. -
logImplctor
Deprecated.Constructor for current log class
-
-
Method Details
-
getInstance
Deprecated.Gets aLoginstance by class.- Parameters:
clazz- a Class.- Returns:
- a
Loginstance.
-
getInstance
Deprecated.Gets aLoginstance by class name.- Parameters:
name- Class name.- Returns:
- a
Loginstance.
-
getLogNames
Deprecated.Returns aStringarray containing the names of all logs known to me.- Returns:
- a
Stringarray containing the names of all logs known to me.
-
makeNewLogInstance
Deprecated.Create a newLogimplementation, based on the given name.The specific
Logimplementation returned is determined by the value of theorg.apache.commons.logging.logproperty. The value oforg.apache.commons.logging.logmay be set to the fully specified name of a class that implements theLoginterface. This class must also have a public constructor that takes a singleStringargument (containing the name of theLogto be constructed.When
org.apache.commons.logging.logis 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(Class<?> logClass) throws LinkageError, ExceptionInInitializerError, NoSuchMethodException, SecurityException Deprecated.Sets the log implementation/log implementation factory by class. The given class must implementLog, and provide a constructor that takes a singleStringargument (containing the name of the log).- Parameters:
logClass- class.- Throws:
LinkageError- if there is missing dependency.ExceptionInInitializerError- unexpected exception has occurred in a static initializer.NoSuchMethodException- if a matching method is not found.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
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 singleStringargument (containing the name of the log).- Parameters:
className- class name.- Throws:
LinkageError- if there is missing dependency.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.
-
LogFactoryinstead - The default factory implementation performs exactly the same algorithm as this class did