[英]jcabi ssh redirect output to null or file
我正在編寫一個小應用程序,通過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);
我想要隱藏控制台輸出或將其重定向到文件。 我查看了源代碼,但似乎無法通過方法調用來完成。 有辦法做我想要的嗎?
謝謝!
您應該禁止在應用程序中記錄日志。 jcabi-ssh正在使用slf4j。 您在日志中看到的是通過slf4j到(最有可能)log4j。 確保com.jcabi.ssh
日志級別設置為ERROR
,你會沒事的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.