Module org.snmp4j

Class JavaLogAdapter

  • All Implemented Interfaces:
    LogAdapter


    public class JavaLogAdapter
    extends java.lang.Object
    implements LogAdapter
    The JavaLogAdapter log adapter provides logging for SNMP4J through the Java logging (java.util.logging).
    Since:
    1.7.2
    Version:
    3.4.1
    Author:
    Frank Fock
    • Constructor Summary

      Constructors 
      Constructor Description
      JavaLogAdapter​(java.util.logging.Logger logger)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void debug​(java.io.Serializable message)
      Logs a debug message.
      void error​(java.io.Serializable message)
      Logs an error message.
      void error​(java.lang.CharSequence message, java.lang.Throwable t)
      Logs an error message.
      void fatal​(java.lang.CharSequence message, java.lang.Throwable t)
      Logs a fatal message.
      void fatal​(java.lang.Object message)
      Logs a fatal message.
      static LogLevel fromJavaToSnmp4jLevel​(java.util.logging.Level level)
      Mapping from java.util.logging.Level to org.snmp4j.log.LogLevel.
      static java.util.logging.Level fromSnmp4jToJdk​(LogLevel logLevel)
      Mapping from org.snmp4j.log.LogLevel to java.util.logging.Level.
      LogLevel getEffectiveLogLevel​()
      Returns the log level that is effective for this log adapter.
      java.util.logging.Logger getJavaLogger​()
      Gets the Java logger of this log adapter.
      java.util.Iterator<java.util.logging.Handler> getLogHandler​()
      Returns the log handlers associated with this logger.
      LogLevel getLogLevel​()
      Returns the log level defined for this log adapter.
      java.lang.String getName​()
      Returns the name of the logger.
      void info​(java.lang.CharSequence message)
      Logs an informational message.
      boolean isDebugEnabled​()
      Checks whether DEBUG level logging is activated for this log adapter.
      boolean isInfoEnabled​()
      Checks whether INFO level logging is activated for this log adapter.
      boolean isWarnEnabled​()
      Checks whether WARN level logging is activated for this log adapter.
      void setLogLevel​(LogLevel logLevel)
      Sets the log level for this log adapter (if applicable).
      java.lang.String toString​()  
      void warn​(java.io.Serializable message)
      Logs an warning message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • JavaLogAdapter

        public JavaLogAdapter​(java.util.logging.Logger logger)
    • Method Detail

      • isDebugEnabled

        public boolean isDebugEnabled​()
        Description copied from interface: LogAdapter
        Checks whether DEBUG level logging is activated for this log adapter.
        Specified by:
        isDebugEnabled in interface LogAdapter
        Returns:
        true if logging is enabled or false otherwise.
      • isInfoEnabled

        public boolean isInfoEnabled​()
        Description copied from interface: LogAdapter
        Checks whether INFO level logging is activated for this log adapter.
        Specified by:
        isInfoEnabled in interface LogAdapter
        Returns:
        true if logging is enabled or false otherwise.
      • isWarnEnabled

        public boolean isWarnEnabled​()
        Description copied from interface: LogAdapter
        Checks whether WARN level logging is activated for this log adapter.
        Specified by:
        isWarnEnabled in interface LogAdapter
        Returns:
        true if logging is enabled or false otherwise.
      • debug

        public void debug​(java.io.Serializable message)
        Description copied from interface: LogAdapter
        Logs a debug message.
        Specified by:
        debug in interface LogAdapter
        Parameters:
        message - the message to log.
      • info

        public void info​(java.lang.CharSequence message)
        Description copied from interface: LogAdapter
        Logs an informational message.
        Specified by:
        info in interface LogAdapter
        Parameters:
        message - the message to log.
      • warn

        public void warn​(java.io.Serializable message)
        Description copied from interface: LogAdapter
        Logs an warning message.
        Specified by:
        warn in interface LogAdapter
        Parameters:
        message - the message to log.
      • error

        public void error​(java.io.Serializable message)
        Description copied from interface: LogAdapter
        Logs an error message.
        Specified by:
        error in interface LogAdapter
        Parameters:
        message - the message to log.
      • error

        public void error​(java.lang.CharSequence message,
                          java.lang.Throwable t)
        Description copied from interface: LogAdapter
        Logs an error message.
        Specified by:
        error in interface LogAdapter
        Parameters:
        message - the message to log.
        t - the exception that caused to error.
      • fatal

        public void fatal​(java.lang.Object message)
        Description copied from interface: LogAdapter
        Logs a fatal message.
        Specified by:
        fatal in interface LogAdapter
        Parameters:
        message - the message to log.
      • fatal

        public void fatal​(java.lang.CharSequence message,
                          java.lang.Throwable t)
        Description copied from interface: LogAdapter
        Logs a fatal message.
        Specified by:
        fatal in interface LogAdapter
        Parameters:
        message - the message to log.
        t - the exception that caused to error.
      • getEffectiveLogLevel

        public LogLevel getEffectiveLogLevel​()
        Description copied from interface: LogAdapter
        Returns the log level that is effective for this log adapter. The effective log level is the first log level different from LogLevel.NONE to the root.
        Specified by:
        getEffectiveLogLevel in interface LogAdapter
        Returns:
        a LogLevel different than LogLevel.NONE.
      • getLogHandler

        public java.util.Iterator<java.util.logging.Handler> getLogHandler​()
        Description copied from interface: LogAdapter
        Returns the log handlers associated with this logger.
        Specified by:
        getLogHandler in interface LogAdapter
        Returns:
        an Iterator of log system dependent log handlers.
      • getLogLevel

        public LogLevel getLogLevel​()
        Description copied from interface: LogAdapter
        Returns the log level defined for this log adapter.
        Specified by:
        getLogLevel in interface LogAdapter
        Returns:
        a LogLevel instance.
      • getName

        public java.lang.String getName​()
        Description copied from interface: LogAdapter
        Returns the name of the logger.
        Specified by:
        getName in interface LogAdapter
        Returns:
        the name of the logger.
      • setLogLevel

        public void setLogLevel​(LogLevel logLevel)
        Description copied from interface: LogAdapter
        Sets the log level for this log adapter (if applicable).
        Specified by:
        setLogLevel in interface LogAdapter
        Parameters:
        logLevel - a LogLevel instance.
      • fromSnmp4jToJdk

        public static java.util.logging.Level fromSnmp4jToJdk​(LogLevel logLevel)
        Mapping from org.snmp4j.log.LogLevel to java.util.logging.Level.
        Parameters:
        logLevel - The LogLevel to mapped
        Returns:
        the Level mapped to or null if null was specified as the parameter.
        Since:
        3.4.1
      • fromJavaToSnmp4jLevel

        public static LogLevel fromJavaToSnmp4jLevel​(java.util.logging.Level level)
        Mapping from java.util.logging.Level to org.snmp4j.log.LogLevel.
        Parameters:
        level - The Level to mapped
        Returns:
        the LogLevel mapped to or LogLevel.NONE if null was specified as the parameter.
        Since:
        3.4.1
      • toString

        public java.lang.String toString​()
        Overrides:
        toString in class java.lang.Object
      • getJavaLogger

        public java.util.logging.Logger getJavaLogger​()
        Gets the Java logger of this log adapter.
        Returns:
        the Java logger.
        Since:
        3.4.1