public class JavaLogAdapter extends java.lang.Object implements LogAdapter
JavaLogAdapter
log adapter provides logging for SNMP4J
through the Java logging (java.util.logging
).Modifier and Type | Field and Description |
---|---|
private java.util.logging.Logger |
logger |
Constructor and Description |
---|
JavaLogAdapter(java.util.logging.Logger logger) |
Modifier and Type | Method and Description |
---|---|
void |
debug(java.io.Serializable message)
Logs a debug message.
|
void |
error(java.lang.CharSequence message,
java.lang.Throwable t)
Logs an error message.
|
void |
error(java.io.Serializable message)
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.
|
private static LogLevel |
fromJavaToSnmp4jLevel(java.util.logging.Level level)
Mapping from
java.util.logging.Level to
org.snmp4j.log.LogLevel . |
private 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.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.
|
private boolean |
isLoggable(LogLevel logLevel) |
boolean |
isWarnEnabled()
Checks whether WARN level logging is activated for this log adapter.
|
private void |
log(LogLevel logLevel,
java.lang.String msg,
java.lang.Throwable t) |
void |
setLogLevel(LogLevel logLevel)
Sets the log level for this log adapter (if applicable).
|
void |
warn(java.io.Serializable message)
Logs an warning message.
|
public boolean isDebugEnabled()
LogAdapter
isDebugEnabled
in interface LogAdapter
true
if logging is enabled or false
otherwise.public boolean isInfoEnabled()
LogAdapter
isInfoEnabled
in interface LogAdapter
true
if logging is enabled or false
otherwise.public boolean isWarnEnabled()
LogAdapter
isWarnEnabled
in interface LogAdapter
true
if logging is enabled or false
otherwise.public void debug(java.io.Serializable message)
LogAdapter
debug
in interface LogAdapter
message
- the message to log.public void info(java.lang.CharSequence message)
LogAdapter
info
in interface LogAdapter
message
- the message to log.public void warn(java.io.Serializable message)
LogAdapter
warn
in interface LogAdapter
message
- the message to log.public void error(java.io.Serializable message)
LogAdapter
error
in interface LogAdapter
message
- the message to log.public void error(java.lang.CharSequence message, java.lang.Throwable t)
LogAdapter
error
in interface LogAdapter
message
- the message to log.t
- the exception that caused to error.public void fatal(java.lang.Object message)
LogAdapter
fatal
in interface LogAdapter
message
- the message to log.public void fatal(java.lang.CharSequence message, java.lang.Throwable t)
LogAdapter
fatal
in interface LogAdapter
message
- the message to log.t
- the exception that caused to error.public LogLevel getEffectiveLogLevel()
LogAdapter
LogLevel.NONE
to the root.getEffectiveLogLevel
in interface LogAdapter
LogLevel.NONE
.public java.util.Iterator<java.util.logging.Handler> getLogHandler()
LogAdapter
getLogHandler
in interface LogAdapter
public LogLevel getLogLevel()
LogAdapter
getLogLevel
in interface LogAdapter
public java.lang.String getName()
LogAdapter
getName
in interface LogAdapter
public void setLogLevel(LogLevel logLevel)
LogAdapter
setLogLevel
in interface LogAdapter
logLevel
- a LogLevel instance.private boolean isLoggable(LogLevel logLevel)
private void log(LogLevel logLevel, java.lang.String msg, java.lang.Throwable t)
private static java.util.logging.Level fromSnmp4jToJdk(LogLevel logLevel)
org.snmp4j.log.LogLevel
to
java.util.logging.Level
.logLevel
- The LogLevel
to mappedLevel
mapped to or null
if
null
was specified as the parameter.private static LogLevel fromJavaToSnmp4jLevel(java.util.logging.Level level)
java.util.logging.Level
to
org.snmp4j.log.LogLevel
.level
- The Level
to mappedLogLevel
mapped to or LogLevel.NONE
if
null
was specified as the parameter.