我正在编写一个小应用程序,通过SSH连接到一组服务器并执行一些命令。我使用的是jcabi-ssh。当我运行程序时,jcabi-ssh会输出到控制台,并显示如下代码行:
[main] WARN com.jcabi.ssh.SSH - Permanently added '192.168.4.2' (RSA) to the list of known hosts.
[main] INFO com.jcabi.ssh.Execution$Default - $ ping -c 1 google.com我的代码片段如下:
Shell shell = new SSHByPassword(targetServer.toString(), Integer.parseInt(port), username.toString(), password.toString());
exitCode=shell.exec("ping -c 1 google.com",stdin,stdout,stderr);我想要隐藏控制台输出或将其重定向到文件。我查看了source,但似乎不能通过方法调用来完成。有没有办法做我想做的事?
谢谢!
发布于 2016-07-19 09:19:02
你应该在你的应用程序中禁止日志记录。jcabi ssh使用的是slf4j。您在日志中看到的是通过slf4j到达(最有可能的) log4j。确保将来自com.jcabi.ssh的日志级别设置为ERROR,这样就可以了。
https://stackoverflow.com/questions/38205920
复制相似问题