Class SLF4JLogFactory


  • public class SLF4JLogFactory
    extends LogFactory

    Concrete subclass of LogFactory which always delegates to the org.slf4j.LoggerFactory class.

    This factory generates instances of SLF4JLog. It will remember previously created instances for the same name, and will return them on repeated requests to the getInstance() method.

    This implementation ignores any configured attributes.

    • 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.Object getAttribute​(java.lang.String name)
      Return the configuration attribute with the specified name (if any), or null if there is no such attribute.
      java.lang.String[] getAttributeNames()
      Return an array containing the names of all currently defined configuration attributes.
      Log getInstance​(java.lang.Class clazz)
      Convenience method to derive a name from the specified class and call getInstance(String) with it.
      Log getInstance​(java.lang.String name)
      Construct (if necessary) and return a Log instance, using the factory's current set of configuration attributes.
      void release()
      Release any internal references to previously created Loginstances returned by this factory.
      void removeAttribute​(java.lang.String name)
      Remove any configuration attribute associated with the specified name.
      void setAttribute​(java.lang.String name, java.lang.Object value)
      Set the configuration attribute with the specified name.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG_PROPERTY

        public static final java.lang.String LOG_PROPERTY
        The name of the system property identifying our Logimplementation class.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SLF4JLogFactory

        public SLF4JLogFactory()
        Public no-arguments constructor required by the lookup mechanism.
    • Method Detail

      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name)
        Return the configuration attribute with the specified name (if any), or null if there is no such attribute.
        Specified by:
        getAttribute in class LogFactory
        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:
        getAttributeNames in class LogFactory
        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 call getInstance(String) with it.
        Specified by:
        getInstance in class LogFactory
        Parameters:
        clazz - Class for which a suitable Log name will be derived
        Throws:
        LogConfigurationException - if a suitable Log instance cannot be returned
      • getInstance

        public Log getInstance​(java.lang.String name)
                        throws LogConfigurationException

        Construct (if necessary) and return a Log instance, using the factory's current set of configuration attributes.

        Specified by:
        getInstance in class LogFactory
        Parameters:
        name - Logical name of the Log instance to be returned (the meaning of this name is only known to the underlying logging implementation that is being wrapped)
        Throws:
        LogConfigurationException - if a suitable Log instance cannot be returned
      • release

        public void release()
        Release any internal references to previously created Loginstances 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:
        release in class LogFactory
      • 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:
        removeAttribute in class LogFactory
        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 a null value is equivalent to calling removeAttribute(name).
        Specified by:
        setAttribute in class LogFactory
        Parameters:
        name - Name of the attribute to set
        value - Value of the attribute to set, or null to remove any setting for this attribute