INT-1655 added support for JSch Loging for SFTP adapter, updated documentation

This commit is contained in:
Oleg Zhurakousky
2010-12-01 16:06:00 -05:00
parent 41d64cdf6b
commit ee5b305260
4 changed files with 62 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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