diff --git a/docs/src/reference/docbook/sftp.xml b/docs/src/reference/docbook/sftp.xml
index 1e8d8ea4b5..804c9a6de2 100644
--- a/docs/src/reference/docbook/sftp.xml
+++ b/docs/src/reference/docbook/sftp.xml
@@ -157,4 +157,22 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp
value that computes the file name based on its original name while also appending a suffix: '-foo'.
+
+
+ SFTP/JSCH Logging
+
+ Since we use JSch libraries (http://www.jcraft.com/jsch/) to provide SFTP support some times you may require
+ more information from the JSch API itself especially if something is not working properly
+ (e.g., Authentication exceptions etc.). Unfortunately JSch does not use commonly used logging facilities and instead
+ relies on the custom implementation of com.jcraft.jsch.Logger interface.
+ Since Spring Integration 2.0.1 we've implemented this interface, so now all you need to do to enable
+ JSch logging is to configure your logger the way you usually do. For example below is sample configuration of a
+ logger using Log4J.
+
+
+
+
+
+
+
diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java
index 58028d49f4..94c278e264 100644
--- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java
+++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java
@@ -30,10 +30,11 @@ import com.jcraft.jsch.UserInfo;
*
* @author Josh Long
* @author Mario Gray
+ * @author Oleg Zhurakousky
* @since 2.0
*/
public class DefaultSftpSessionFactory implements SessionFactory {
-
+
private volatile String host;
private volatile int port = 22; // the default
@@ -97,6 +98,8 @@ public class DefaultSftpSessionFactory implements SessionFactory {
}
private com.jcraft.jsch.Session initJschSession() throws Exception {
+ JSch.setLogger(new JschLogger());
+
if (this.port <= 0) {
this.port = 22;
}
diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/JschLogger.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/JschLogger.java
new file mode 100644
index 0000000000..942288214c
--- /dev/null
+++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/JschLogger.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2002-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.integration.sftp.session;
+
+import org.apache.log4j.Level;
+
+import com.jcraft.jsch.Logger;
+
+/**
+ * @author Oleg Zhurakousky
+ * @since 2.0.1
+ */
+class JschLogger implements Logger {
+
+ private final static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("com.jcraft.jsch");
+
+ public boolean isEnabled(int level) {
+ return true;
+ }
+
+ public void log(int level, String message) {
+ logger.log(Level.toLevel(level), message);
+ }
+}
diff --git a/spring-integration-sftp/src/test/resources/log4j.properties b/spring-integration-sftp/src/test/resources/log4j.properties
index c4672eb722..b1f9721f47 100644
--- a/spring-integration-sftp/src/test/resources/log4j.properties
+++ b/spring-integration-sftp/src/test/resources/log4j.properties
@@ -4,5 +4,6 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
-log4j.category.org.springframework=WARN
-log4j.category.org.springframework.integration=DEBUG
+log4j.category.com.jcraft.jsch=DEBUG
+log4j.category.org.springframework.integration=WARN
+log4j.category.org.springframework.integration.sftp=DEBUG