Apache Commons Net library does not seem to send anything to any "logger".
Can I somehow obtain a log file from an (FTP) session, for debugging purposes? For example raw FTP commands and responses from the server, like this:
220 Welcome
USER *******
331 Password required for ...
PASS *******
230 Logged on
TYPE I
200 Type set to I
QUIT
221 Goodbye
All protocol implementations in Apache Commons Net, including
FTPClient
, derive fromSocketClient
, which has a methodaddProtocolCommandListener
. You can pass it an implementation ofProtocolCommandListener
to implement logging.There's a ready-made implementation
PrintCommandListener
, which prints the protocol log to providedPrintStream
.With a code like this:
..., you will get exactly the output that you have asked for.