- java.lang.Object
-
- org.snmp4j.log.JavaLogAdapter
-
- All Implemented Interfaces:
LogAdapter
public class JavaLogAdapter extends java.lang.Object implements LogAdapter
TheJavaLogAdapter
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 fromjava.util.logging.Level
toorg.snmp4j.log.LogLevel
.static java.util.logging.Level
fromSnmp4jToJdk(LogLevel logLevel)
Mapping fromorg.snmp4j.log.LogLevel
tojava.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 interface org.snmp4j.log.LogAdapter
isLogLevelEnabled, log, removeAllHandlers, setLogHandler
-
-
-
-
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 interfaceLogAdapter
- Returns:
true
if logging is enabled orfalse
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 interfaceLogAdapter
- Returns:
true
if logging is enabled orfalse
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 interfaceLogAdapter
- Returns:
true
if logging is enabled orfalse
otherwise.
-
debug
public void debug(java.io.Serializable message)
Description copied from interface:LogAdapter
Logs a debug message.- Specified by:
debug
in interfaceLogAdapter
- 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 interfaceLogAdapter
- 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 interfaceLogAdapter
- 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 interfaceLogAdapter
- 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 interfaceLogAdapter
- 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 interfaceLogAdapter
- 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 interfaceLogAdapter
- 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 fromLogLevel.NONE
to the root.- Specified by:
getEffectiveLogLevel
in interfaceLogAdapter
- 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 interfaceLogAdapter
- 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 interfaceLogAdapter
- 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 interfaceLogAdapter
- 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 interfaceLogAdapter
- Parameters:
logLevel
- a LogLevel instance.
-
fromSnmp4jToJdk
public static java.util.logging.Level fromSnmp4jToJdk(LogLevel logLevel)
Mapping fromorg.snmp4j.log.LogLevel
tojava.util.logging.Level
.- Parameters:
logLevel
- TheLogLevel
to mapped- Returns:
- the
Level
mapped to ornull
ifnull
was specified as the parameter. - Since:
- 3.4.1
-
fromJavaToSnmp4jLevel
public static LogLevel fromJavaToSnmp4jLevel(java.util.logging.Level level)
Mapping fromjava.util.logging.Level
toorg.snmp4j.log.LogLevel
.- Parameters:
level
- TheLevel
to mapped- Returns:
- the
LogLevel
mapped to orLogLevel.NONE
ifnull
was specified as the parameter. - Since:
- 3.4.1
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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
-
-