Module org.snmp4j

Class LogFactory

  • Direct Known Subclasses:
    ConsoleLogFactory, JavaLogFactory

    public class LogFactory
    extends Object
    The LogFactory singleton is used by SNMP4J to determine the logging framework used to process SNMP4J log messages. By default NoLogger instances are used.
    Since:
    1.2.1
    Version:
    3.4.1
    Author:
    Frank Fock
    • Constructor Detail

      • LogFactory

        public LogFactory()
    • Method Detail

      • getLogger

        public static LogAdapter getLogger​(Class<?> c)
        Gets the logger for the supplied class.
        Parameters:
        c - the class for which a logger needs to be created.
        Returns:
        the LogAdapter instance.
      • getRootLogger

        public LogAdapter getRootLogger()
        Returns the top level logger.
        Returns:
        a LogAdapter instance.
        Since:
        1.7
      • getLogger

        public static LogAdapter getLogger​(String className)
        Gets the logger for the supplied class name.
        Parameters:
        className - the class name for which a logger needs to be created.
        Returns:
        the LogAdapter instance.
        Since:
        1.7
      • createLogger

        protected LogAdapter createLogger​(Class<?> c)
        Creates a Logger for the specified class. This method returns the NoLogger logger instance which disables logging. Overwrite this method the return a custom logger to enable logging for SNMP4J.
        Parameters:
        c - the class for which a logger needs to be created.
        Returns:
        the LogAdapter instance.
      • createLogger

        protected LogAdapter createLogger​(String className)
        Creates a Logger for the specified class. This method returns the NoLogger logger instance which disables logging. Overwrite this method the return a custom logger to enable logging for SNMP4J.
        Parameters:
        className - the class name for which a logger needs to be created.
        Returns:
        the LogAdapter instance.
        Since:
        1.7
      • setLogFactory

        public static void setLogFactory​(LogFactory factory)
        Sets the log factory to be used by SNMP4J. Call this method before any other SNMP4J class is referenced or created to set and use a custom log factory.
        Parameters:
        factory - a LogFactory instance.
      • loggers

        public Iterator<LogAdapter> loggers()
        Returns all available LogAdapters in depth first order.
        Returns:
        a read-only Iterator.
        Since:
        1.7
      • resetLogger

        public void resetLogger​(LogAdapter logger)
        Close all handlers of a logger and set its level to null if it is not the root logger.
        Parameters:
        logger - the logger to be reset.
        Since:
        3.4.1
      • getLoggerConfigPrefix

        public String getLoggerConfigPrefix()
      • getLogHandlerConfigPrefix

        public String getLogHandlerConfigPrefix()
      • setLogHandlerConfigPrefix

        public void setLogHandlerConfigPrefix​(String logHandlerConfigPrefix)
        Set the properties name prefix, including the trailing ".", used by updateConfiguration(Properties) and writeConfiguration(Properties) for log handler properties.
        Parameters:
        logHandlerConfigPrefix - the prefix for log handler configuration properties.
        Since:
        3.4.1
      • reset

        public void reset()
        Reset the logging configuration. For all named log adapters, the reset operation removes and closes all handlers (log factory specific) and (except for the root logger) sets the level to null. The root logger's level is set to LogLevel.INFO.
        Since:
        3.4.1
      • removeAllHandlers

        protected void removeAllHandlers​(LogAdapter logAdapter)
      • writeConfiguration

        public void writeConfiguration​(Properties config)
      • writeConfiguration

        protected void writeConfiguration​(Properties config,
                                          LogAdapter logAdapter)