Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

Enable command/response logging on tFTPxxx components

Question

How do you log the commands from a Talend Job and the responses from the server on FTP communications?

 

Answer

Talend FTP components are wrapping the FTPClient class of the edtFTPj library. It can trace the commands/responses, but it is not enabled on Talend components.

 

You can enable it by adding a Listener into the FTPClient instance, as shown below:

{
  com.enterprisedt.net.ftp.FTPClient ftpclient = (com.enterprisedt.net.ftp.FTPClient) globalMap.get("conn_tFTPConnection_1");

  ftpclient.setMessageListener(new com.enterprisedt.net.ftp.FTPMessageListener(){
    public void logCommand(String cmd){
       log.debug(" MessageListener - Command - " + cmd);
    }
    public void logReply(String reply){
      log.debug(" MessageListener - Reply - " + reply);
    }
  });
}

This Listener is called whenever FTPClient posts a command to the server (logCommand()), and receives a response from the server (logReply()).

 

In the example below, the code exports the log message into the Job log4j logger at the DEBUG level.

Listener.png

 

MessageLog.png

Version history
Revision #:
9 of 9
Last update:
‎03-25-2020 08:36 AM
Updated by:
 
Contributors