Spring Integration FTP低级别日志记录



Spring Integration FTP中的DefaultFtpSessionFactory为底层客户端API提供了抽象。当我们需要解决FTP连接和传输问题时,是否可以配置日志以打印较低级别的FTP连接详细信息。在org.springframework上启用TRACE后,我们只会收到连接到FTP站点的消息和传输的文件。

Spring Integration FTP支持完全基于Apache commons-net。看起来我们在DefaultFtpSessionFactory中使用的org.apache.commons.net.ftp.FTPClient类并没有一些日志挂钩。但是,也可以将您自己的ProtocolCommandListener注入到该FTPClient中,例如PrintCommandListener:启用FTP协议的Apache Commons Net中的日志记录。

在这种情况下,DefaultFtpSessionFactory应该被覆盖,并且这样的addProtocolCommandListener()定制应该从postProcessClientBeforeConnect(T client)实现中调用。