| |
|
| java.lang.Object org.apache.commons.logging.LogFactory org.apache.commons.logging.impl.LogFactoryImpl
LogFactoryImpl | public class LogFactoryImpl extends LogFactory (Code) | | Concrete subclass of
LogFactory that implements the
following algorithm to dynamically select a logging implementation
class to instantiate a wrapper for.
- Use a factory configuration attribute named
org.apache.commons.logging.Log to identify the
requested implementation class.
- Use the
org.apache.commons.logging.Log system property
to identify the requested implementation class.
- 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.SimpleLog .
If the selected
Log implementation class has a
setLogFactory() method that accepts a
LogFactory parameter, this method will be called on each newly created instance
to identify the associated factory. This makes factory configuration
attributes available to the Log instance, if it so desires.
This factory will remember previously created Log instances
for the same name, and will return them on repeated requests to the
getInstance() method.
author: Rod Waldhoff author: Craig R. McClanahan author: Richard A. Sitze author: Brian Stansberry version: $Revision: 399224 $ $Date: 2006-05-03 10:25:54 +0100 (Wed, 03 May 2006) $ |
Constructor Summary | |
public | LogFactoryImpl() Public no-arguments constructor required by the lookup mechanism. |
ALLOW_FLAWED_CONTEXT_PROPERTY | final public static String ALLOW_FLAWED_CONTEXT_PROPERTY(Code) | | The name (org.apache.commons.logging.Log.allowFlawedContext )
of the system property which can be set true/false to
determine system behaviour when a bad context-classloader is encountered.
When set to false, a LogConfigurationException is thrown if
LogFactoryImpl is loaded via a child classloader of the TCCL (this
should never happen in sane systems).
Default behaviour: true (tolerates bad context classloaders)
See also method setAttribute.
|
ALLOW_FLAWED_DISCOVERY_PROPERTY | final public static String ALLOW_FLAWED_DISCOVERY_PROPERTY(Code) | | The name (org.apache.commons.logging.Log.allowFlawedDiscovery )
of the system property which can be set true/false to
determine system behaviour when a bad logging adapter class is
encountered during logging discovery. When set to false, an
exception will be thrown and the app will fail to start. When set
to true, discovery will continue (though the user might end up
with a different logging implementation than they expected).
Default behaviour: true (tolerates bad logging adapters)
See also method setAttribute.
|
ALLOW_FLAWED_HIERARCHY_PROPERTY | final public static String ALLOW_FLAWED_HIERARCHY_PROPERTY(Code) | | The name (org.apache.commons.logging.Log.allowFlawedHierarchy )
of the system property which can be set true/false to
determine system behaviour when a logging adapter class is
encountered which has bound to the wrong Log class implementation.
When set to false, an exception will be thrown and the app will fail
to start. When set to true, discovery will continue (though the user
might end up with a different logging implementation than they expected).
Default behaviour: true (tolerates bad Log class hierarchy)
See also method setAttribute.
|
LOG_PROPERTY | final public static String LOG_PROPERTY(Code) | | The name (org.apache.commons.logging.Log ) of the system
property identifying our
Log implementation class.
|
LOG_PROPERTY_OLD | final protected static String LOG_PROPERTY_OLD(Code) | | The deprecated system property used for backwards compatibility with
old versions of JCL.
|
logConstructor | protected Constructor logConstructor(Code) | | The one-argument constructor of the
org.apache.commons.logging.Log implementation class that will be used to create new instances.
This value is initialized by getLogConstructor() ,
and then returned repeatedly.
|
logConstructorSignature | protected Class logConstructorSignature(Code) | | The signature of the Constructor to be used.
|
logMethodSignature | protected Class logMethodSignature(Code) | | The signature of the setLogFactory method to be used.
|
LogFactoryImpl | public LogFactoryImpl()(Code) | | Public no-arguments constructor required by the lookup mechanism.
|
getAttribute | public Object getAttribute(String name)(Code) | | Return the configuration attribute with the specified name (if any),
or null if there is no such attribute.
Parameters: name - Name of the attribute to return |
getAttributeNames | public String[] getAttributeNames()(Code) | | Return an array containing the names of all currently defined
configuration attributes. If there are no such attributes, a zero
length array is returned.
|
getClassLoader | protected static ClassLoader getClassLoader(Class clazz)(Code) | | Workaround for bug in Java1.2; in theory this method is not needed.
See LogFactory.getClassLoader.
since: 1.1 |
getContextClassLoader | protected static ClassLoader getContextClassLoader() throws LogConfigurationException(Code) | | Gets the context classloader.
This method is a workaround for a java 1.2 compiler bug.
since: 1.1 |
getInstance | public Log getInstance(Class clazz) throws LogConfigurationException(Code) | | Convenience method to derive a name from the specified class and
call getInstance(String) with it.
Parameters: clazz - Class for which a suitable Log name will be derived exception: LogConfigurationException - if a suitable Log instance cannot be returned |
getInstance | public Log getInstance(String name) throws LogConfigurationException(Code) | | Construct (if necessary) and return a Log instance,
using the factory's current set of configuration attributes.
NOTE - Depending upon the implementation of
the LogFactory you are using, the Log
instance you are returned may or may not be local to the current
application, and may or may not be returned again on a subsequent
call with the same name argument.
Parameters: name - Logical name of the Log instance to bereturned (the meaning of this name is only known to the underlyinglogging implementation that is being wrapped) exception: LogConfigurationException - if a suitable Log instance cannot be returned |
getLogClassName | protected String getLogClassName()(Code) | | Return the fully qualified Java classname of the
Log implementation we will be using.
|
isDiagnosticsEnabled | protected static boolean isDiagnosticsEnabled()(Code) | | Workaround for bug in Java1.2; in theory this method is not needed.
See LogFactory.isDiagnosticsEnabled.
|
isJdk13LumberjackAvailable | protected boolean isJdk13LumberjackAvailable()(Code) | | Is JDK 1.3 with Lumberjack logging available?
|
isJdk14Available | protected boolean isJdk14Available()(Code) | | Return true if JDK 1.4 or later logging
is available. Also checks that the Throwable class
supports getStackTrace() , which is required by
Jdk14Logger.
|
isLog4JAvailable | protected boolean isLog4JAvailable()(Code) | | Is a Log4J implementation available?
|
logDiagnostic | protected void logDiagnostic(String msg)(Code) | | Output a diagnostic message to a user-specified destination (if the
user has enabled diagnostic logging).
Parameters: msg - diagnostic message since: 1.1 |
release | public void release()(Code) | | Release any internal references to previously created
org.apache.commons.logging.Log instances returned by this factory. This is useful in environments
like servlet containers, which implement application reloading by
throwing away a ClassLoader. Dangling references to objects in that
class loader would prevent garbage collection.
|
removeAttribute | public void removeAttribute(String name)(Code) | | Remove any configuration attribute associated with the specified name.
If there is no such attribute, no action is taken.
Parameters: name - Name of the attribute to remove |
setAttribute | public void setAttribute(String name, Object value)(Code) | | Set the configuration attribute with the specified name. Calling
this with a null value is equivalent to calling
removeAttribute(name) .
This method can be used to set logging configuration programmatically
rather than via system properties. It can also be used in code running
within a container (such as a webapp) to configure behaviour on a
per-component level instead of globally as system properties would do.
To use this method instead of a system property, call
LogFactory.getFactory().setAttribute(...)
This must be done before the first Log object is created; configuration
changes after that point will be ignored.
This method is also called automatically if LogFactory detects a
commons-logging.properties file; every entry in that file is set
automatically as an attribute here.
Parameters: name - Name of the attribute to set Parameters: value - Value of the attribute to set, or null to remove any setting for this attribute |
|
|
|