Package org.kiwiproject.jsch
Class JSchSlf4jLogger
- java.lang.Object
-
- org.kiwiproject.jsch.JSchSlf4jLogger
-
- All Implemented Interfaces:
com.jcraft.jsch.Logger
public class JSchSlf4jLogger extends Object implements com.jcraft.jsch.Logger
Custom logger implementing Jsch'sLoggerclass.Some implementation notes:
- JSch's INFO level logging is very verbose, so we are treating it like DEBUG level
- Jsch has both ERROR and FATAL levels, but SLF4J only has ERROR, so we treat both as ERROR in SLF4J
-
-
Constructor Summary
Constructors Constructor Description JSchSlf4jLogger()Construct an instance with a default logger, e.g.JSchSlf4jLogger(org.slf4j.Logger slf4jLogger)Construct an instance using the given SLF4J logger.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisEnabled(int level)Is the given level enabled?voidlog(int level, String message)Log the given message at the given level.
-
-
-
Constructor Detail
-
JSchSlf4jLogger
public JSchSlf4jLogger()
Construct an instance with a default logger, e.g. fororg.kiwiproject.jsch.JSchSlf4jLogger.Usually you should use
JSchSlf4jLogger(Logger)in order to specify the SLF4JLoggerexplicitly to control the logging level and logger name.
-
JSchSlf4jLogger
public JSchSlf4jLogger(org.slf4j.Logger slf4jLogger)
Construct an instance using the given SLF4J logger.- Parameters:
slf4jLogger- the SLF4JLoggerthat will be the destination for JSch logging output.
-
-
Method Detail
-
isEnabled
public boolean isEnabled(int level)
Is the given level enabled?- Specified by:
isEnabledin interfacecom.jcraft.jsch.Logger- Parameters:
level- one of the public constants inLogger- Returns:
- true if the level is enabled in the underlying SLF4J logger.
-
log
public void log(int level, String message)Log the given message at the given level.If provided an invalid level, a message will be logged about the invalid level, along with the given message, at the SLF4J ERROR level. This is intended to provide both information about the problem as well as provide the original message, rather than throwing an exception or suppressing the message.
- Specified by:
login interfacecom.jcraft.jsch.Logger- Parameters:
level- one of the public constants inLoggermessage- the message to log
-
-