We use the excellent JSCH library as a part of the commons-vfs library in VFS transport. If you want to enable debugging for the underline JSCH library you'll have to implement a small class with the required logic. Following is an example
<proxy name="SFTPVFSProxy" transports="vfs" startOnLoad="true" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<log level="full"/>
<property name="File"
expression="fn:concat('test-', get-property('transport', 'FILE_PATH'))"
scope="default"/>
<property name="transport.vfs.ReplyFileName"
expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.xml')"
scope="transport"/>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint name="endpoint_urn_uuid_A1546EFFD75FC9CCED785986339425964585275">
<address uri="vfs:sftp://rajika:rajika123@10.100.1.12/home/rajika/out"/>
</endpoint>
</send>
</inSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">15</parameter>
<parameter name="transport.vfs.MoveAfterProcess">vfs:sftp://rajika:rajika123@10.100.1.12/home/rajika/original</parameter>
<parameter name="transport.vfs.FileURI">vfs:sftp://rajika:rajika123@10.100.1.12/home/rajika/in/test.xml</parameter>
<parameter name="transport.vfs.MoveAfterFailure">vfs:sftp://rajika:rajika123@10.100.1.12/home/rajika/original</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
<parameter name="transport.vfs.ContentType">application/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
</proxy>
public static class JSchLogger implements Logger {
public boolean isEnabled(int level) {
switch (level) {
case FATAL:
return log.isFatalEnabled();
case ERROR:
return log.isErrorEnabled();
case WARN:
return log.isWarnEnabled();
case INFO:
return log.isInfoEnabled();
default:
return log.isDebugEnabled();
}
}
public void log(int level, String message) {
switch (level) {
case FATAL:
log.fatal("[JSCH] " + message);
break;
case ERROR:
log.error("[JSCH] " + message);
break;
case WARN:
log.warn("[JSCH] " + message);
break;
case INFO:
log.info("[JSCH] " + message);
break;
default:
log.debug("[JSCH] " + message);
}
}
}
The logger is given by:
private static final Log log = LogFactory.getLog(SftpClientFactory.class);
And the logger should be set into the JSch.
JSch.setLogger(new JSchLogger());
I just submitted a patch,VFS-441 for commons-vfs so that we can have this improvement with the next commons-vfs release.
How ever in the JSCH version 0.1.31 it seems that we have to provide the relative path for the file name where as in version 0.1.41 it accepts the absolute path.
While testing this you may also need to enable clear text password support for the remote sshd as describe here.
There is an entry that I wrote earlier on the same subject.
0 comments:
Post a Comment