I is impossible to debug FTP server. We have no control over it. We just use it as our EDI communication service.
I set log4j as following, but no debug info from package "com.enterprisedt.net.ftp" get written to ftpClient.log file.
<appender name="FTPClient_FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/ftpClient.log"/>
<param name="Append" value="true"/>
<param name="Threshold" value="DEBUG"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
</layout>
</appender>
<category name="com.enterprisedt.net.ftp">
<priority value="DEBUG"/>
<appender-ref ref="FTPClient_FILE"/>
</category>
But when I added following, it writes to log file. FileTransferClient is class that I wrote to do all the ftp process like connect, login, quit... using FtpClient class.
<category name="com.FileTransferClient">
<priority value="DEBUG"/>
<appender-ref ref="FTPClient_FILE"/>
</category>
Here is the code in FileTransferClient
FTPClient fTPClient = new FTPClient();
fTPClient.setTimeout(1000);// set to 1 second
int tryCount = 1;
while (true){
try {
log.debug("XXXXXXXX before ftp.connect() - " + tryCount);
fTPClient.connect();
log.debug("XXXXXXXX after ftp.connect() - " + tryCount);
fTPClient.login(user,pass);
log.debug("XXXXXXXX after ftp.login() - " + tryCount);
CONNECTED_COUNT++;
log.debug("CONNECTED_COUNT="+CONNECTED_COUNT);
break;
}catch(Exception e){
if (tryCount < 10){
log.debug("Could not get file, retrying");
ftp.quit();
CONNECTION_COLOSED_COUNT++ ;
log.debug("CONNECTION_COLOSED_COUNT="+CONNECTION_COLOSED_COUNT);
tryCount++;
}else{
log.debug("XXXXXXXX Failed to connect to host - " + host + "\n" + e.getMessage());
e.printStackTrace();
throw new IOException("Failed to connect to host - " + host + "\n" + e.getMessage());
}
}
}
ftp.quit();
CONNECTION_COLOSED_COUNT++ ;
log.debug("CONNECTION_COLOSED_COUNT="+CONNECTION_COLOSED_COUNT);
Anded the log contents when the ftp operation are success. But noting from com.enterprisedt.net.ftp.FTPClient
2008-03-10 11:45:15,389 DEBUG [com.FileTransferClient] (RMI TCP Connection(24)-192.168.1.175) XXXXXXXX before ftp.connect() - 1
2008-03-10 11:46:35,104 DEBUG [com.FileTransferClient] (RMI TCP Connection(24)-192.168.1.175) XXXXXXXX after ftp.connect() - 1
2008-03-10 11:46:55,635 DEBUG [com.FileTransferClient] (RMI TCP Connection(24)-192.168.1.175) XXXXXXXX after ftp.login() - 1
2008-03-10 11:46:55,635 DEBUG [com.FileTransferClient] (RMI TCP Connection(24)-192.168.1.175) CONNECTED_COUNT=1
2008-03-10 11:46:56,338 DEBUG [com.FileTransferClient] (RMI TCP Connection(24)-192.168.1.175) CONNECTION_COLOSED_COUNT=1
Did I do anyting wrong to config the logging for com.enterprisedt.net.ftp.FTPClient?
Thank you for your help!
Deping