Tag: jsch

JSch登录文件

我想将JSch日志保存在文件中,因为它在控制台中没有显示任何内容。 这是我的代码: public boolean openConnection() throws ItsSshException { boolean connectSuccess = false; JSch.setLogger(new MyLogger()); Properties config = new Properties(); config.put(“StrictHostKeyChecking”, “no”); jschSSH.setConfig(config); try { sshSession = jschSSH.getSession(username, hostname, port); sshSession.setPassword(password); sshSession.connect(connectionTimeout); LOGGER.info(“Connection timeout : ” + connectionTimeout); Thread.sleep(1000); sshHChannel = sshSession.openChannel(“shell”); sshHChannel.connect(); in = sshHChannel.getInputStream(); out = new PrintStream(sshHChannel.getOutputStream()); clearInitialSocketState(); connectSuccess = true; } catch […]