Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 启用Apache Commons Net中FTP协议的登录_Java_Logging_Ftp_Apache Commons Net - Fatal编程技术网

Java 启用Apache Commons Net中FTP协议的登录

Java 启用Apache Commons Net中FTP协议的登录,java,logging,ftp,apache-commons-net,Java,Logging,Ftp,Apache Commons Net,ApacheCommonsNetLibrary似乎没有向任何“记录器”发送任何内容 出于调试目的,我是否可以从(FTP)会话中获取日志文件?例如,来自服务器的原始FTP命令和响应,如下所示: ftpClient.addProtocolCommandListener( new PrintCommandListener( new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")), true))

ApacheCommonsNetLibrary似乎没有向任何“记录器”发送任何内容

出于调试目的,我是否可以从(FTP)会话中获取日志文件?例如,来自服务器的原始FTP命令和响应,如下所示:

ftpClient.addProtocolCommandListener(
    new PrintCommandListener(
        new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")), true));
欢迎光临 使用者******* 331…需要密码。。。 通过******* 230已登录 第一类 200类型设置为I 退出 221再见
Apache Commons Net中的所有协议实现,包括
FTPClient
,都源于,它有一个方法。您可以将的实现传递给它以实现日志记录

有一个现成的实现,它将协议日志打印到提供的
PrintStream

代码如下:

ftpClient.addProtocolCommandListener(
    new PrintCommandListener(
        new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")), true));
…,您将获得您所要求的确切输出