Package org.apache.commons.logging.impl
Class SLF4JLogFactory
- java.lang.Object
-
- org.apache.commons.logging.LogFactory
-
- org.apache.commons.logging.impl.SLF4JLogFactory
-
public class SLF4JLogFactory extends LogFactory
Concrete subclass of
LogFactorywhich always delegates to theorg.slf4j.LoggerFactoryclass.This factory generates instances of
SLF4JLog. It will remember previously created instances for the same name, and will return them on repeated requests to thegetInstance()method.This implementation ignores any configured attributes.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLOG_PROPERTYThe name of the system property identifying ourLogimplementation class.-
Fields inherited from class org.apache.commons.logging.LogFactory
DIAGNOSTICS_DEST_PROPERTY, FACTORY_DEFAULT, FACTORY_PROPERTIES, FACTORY_PROPERTY, HASHTABLE_IMPLEMENTATION_PROPERTY, PRIORITY_KEY, TCCL_KEY
-
-
Constructor Summary
Constructors Constructor Description SLF4JLogFactory()Public no-arguments constructor required by the lookup mechanism.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetAttribute(java.lang.String name)Return the configuration attribute with the specified name (if any), ornullif there is no such attribute.java.lang.String[]getAttributeNames()Return an array containing the names of all currently defined configuration attributes.LoggetInstance(java.lang.Class clazz)Convenience method to derive a name from the specified class and callgetInstance(String)with it.LoggetInstance(java.lang.String name)Construct (if necessary) and return aLoginstance, using the factory's current set of configuration attributes.voidrelease()Release any internal references to previously createdLoginstances returned by this factory.voidremoveAttribute(java.lang.String name)Remove any configuration attribute associated with the specified name.voidsetAttribute(java.lang.String name, java.lang.Object value)Set the configuration attribute with the specified name.-
Methods inherited from class org.apache.commons.logging.LogFactory
getFactory, getLog, getLog, objectId, release, releaseAll
-
-
-
-
Field Detail
-
LOG_PROPERTY
public static final java.lang.String LOG_PROPERTY
The name of the system property identifying ourLogimplementation class.- See Also:
- Constant Field Values
-
-
Method Detail
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Return the configuration attribute with the specified name (if any), ornullif there is no such attribute.- Specified by:
getAttributein classLogFactory- Parameters:
name- Name of the attribute to return- Returns:
- configuration attribute
-
getAttributeNames
public java.lang.String[] getAttributeNames()
Return an array containing the names of all currently defined configuration attributes. If there are no such attributes, a zero length array is returned.- Specified by:
getAttributeNamesin classLogFactory- Returns:
- names of all currently defined configuration attributes
-
getInstance
public Log getInstance(java.lang.Class clazz) throws LogConfigurationException
Convenience method to derive a name from the specified class and callgetInstance(String)with it.- Specified by:
getInstancein classLogFactory- Parameters:
clazz- Class for which a suitable Log name will be derived- Throws:
LogConfigurationException- if a suitableLoginstance cannot be returned
-
getInstance
public Log getInstance(java.lang.String name) throws LogConfigurationException
Construct (if necessary) and return a
Loginstance, using the factory's current set of configuration attributes.- Specified by:
getInstancein classLogFactory- Parameters:
name- Logical name of theLoginstance to be returned (the meaning of this name is only known to the underlying logging implementation that is being wrapped)- Throws:
LogConfigurationException- if a suitableLoginstance cannot be returned
-
release
public void release()
Release any internal references to previously createdLoginstances 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.- Specified by:
releasein classLogFactory
-
removeAttribute
public void removeAttribute(java.lang.String name)
Remove any configuration attribute associated with the specified name. If there is no such attribute, no action is taken.- Specified by:
removeAttributein classLogFactory- Parameters:
name- Name of the attribute to remove
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)Set the configuration attribute with the specified name. Calling this with anullvalue is equivalent to callingremoveAttribute(name).- Specified by:
setAttributein classLogFactory- Parameters:
name- Name of the attribute to setvalue- Value of the attribute to set, ornullto remove any setting for this attribute
-
-