2016-07-05 102 views
1

我正在编写一个小应用程序,通过SSH连接到服务器列表并执行一些命令。我正在使用jcabi-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,但似乎无法通过方法调用完成。有没有办法做我想要的?

谢谢!

回答

0

您应该在应用程序中禁止登录。 jcabi-ssh正在使用slf4j。你在日志中看到的是通过slf4j到(最可能)log4j。确保日志级别从com.jcabi.ssh设置为ERROR,你会没事的。