com.jcraft.jsch.JSch.setLogger()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(270)

本文整理了Java中com.jcraft.jsch.JSch.setLogger()方法的一些代码示例,展示了JSch.setLogger()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSch.setLogger()方法的具体详情如下:
包路径:com.jcraft.jsch.JSch
类名称:JSch
方法名:setLogger

JSch.setLogger介绍

[英]sets the Logger to be used by this library.
[中]设置此库要使用的记录器。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

private Session createSession(String host, Args args) throws JSchException {
 JSch jsch = new JSch();
 for (String keyFile : getKeyFiles()) {
  jsch.addIdentity(keyFile);
 }
 JSch.setLogger(new LogAdapter());
 Session session = jsch.getSession(args.user, host, args.sshPort);
 session.setConfig("StrictHostKeyChecking", "no");
 return session;
}

代码示例来源:origin: apache/incubator-gobblin

@Override
 protected JSch createDefaultJSch(FS fs) throws JSchException {
  if (GitMonitoringService.this.isJschLoggerEnabled) {
   JSch.setLogger(new JschLogger());
  }
  JSch defaultJSch = super.createDefaultJSch(fs);
  defaultJSch.getIdentityRepository().removeAll();
  if (GitMonitoringService.this.privateKeyPath != null) {
   defaultJSch.addIdentity(GitMonitoringService.this.privateKeyPath, GitMonitoringService.this.passphrase);
  } else {
   defaultJSch.addIdentity("gaas-git", GitMonitoringService.this.privateKey, null,
     GitMonitoringService.this.passphrase.getBytes(Charset.forName("UTF-8")));
  }
  if (!Strings.isNullOrEmpty(GitMonitoringService.this.knownHosts)) {
   defaultJSch.setKnownHosts(new ByteArrayInputStream(GitMonitoringService.this.knownHosts.getBytes(Charset.forName("UTF-8"))));
  } else if (!Strings.isNullOrEmpty(GitMonitoringService.this.knownHostsFile)) {
   defaultJSch.setKnownHosts(GitMonitoringService.this.knownHostsFile);
  }
  return defaultJSch;
 }
};

代码示例来源:origin: apache/incubator-gobblin

int proxyPort = this.state.getPropAsInt(ConfigurationKeys.SOURCE_CONN_USE_PROXY_PORT, -1);
JSch.setLogger(new JSchLogger());
JSch jsch = new JSch();

代码示例来源:origin: com.helger/ph-web

public static void shutdown ()
 {
  // Set null logger
  JSch.setLogger (null);
 }
}

代码示例来源:origin: org.rundeck/rundeck-core

/**
 * Set the thread-inherited logger with a loglevel on Jsch
 *
 * @param logger logger
 * @param loggingLevel level
 */
private void setThreadLogger(PluginLogger logger, int loggingLevel) {
  pluginLogger.set(logger);
  logLevel.set(loggingLevel);
  JSch.setLogger(this);
}

代码示例来源:origin: org.rundeck/rundeck-core

/**
 * Set the thread-inherited logger with a loglevel on Jsch
 *
 * @param logger logger
 * @param loggingLevel level
 */
private void setThreadLogger(BaseLogger logger, int loggingLevel) {
  baseLogger.set(logger);
  logLevel.set(loggingLevel);
  JSch.setLogger(this);
}
/**

代码示例来源:origin: com.helger/ph-web

public static void init ()
{
 // Set static logger
 JSch.setLogger (new JSchLoggerSLF4J (JSch.class));
}

代码示例来源:origin: io.hops/hadoop-common

private Session createSession(String host, Args args) throws JSchException {
 JSch jsch = new JSch();
 for (String keyFile : getKeyFiles()) {
  jsch.addIdentity(keyFile);
 }
 JSch.setLogger(new LogAdapter());
 Session session = jsch.getSession(args.user, host, args.sshPort);
 session.setConfig("StrictHostKeyChecking", "no");
 return session;
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

private Session createSession(String host, Args args) throws JSchException {
 JSch jsch = new JSch();
 for (String keyFile : getKeyFiles()) {
  jsch.addIdentity(keyFile);
 }
 JSch.setLogger(new LogAdapter());
 Session session = jsch.getSession(args.user, host, args.sshPort);
 session.setConfig("StrictHostKeyChecking", "no");
 return session;
}

代码示例来源:origin: org.apache.camel/camel-jsch

protected void initJsch()  {
  JSch.setConfig("StrictHostKeyChecking",  "yes");
  JSch.setLogger(new com.jcraft.jsch.Logger() {
    @Override
    public boolean isEnabled(int level) {
      return level == FATAL || level == ERROR ? LOG.isErrorEnabled()
          : level == WARN ? LOG.isWarnEnabled()
          : level == INFO ? LOG.isInfoEnabled() : LOG.isDebugEnabled();
    }
    @Override
    public void log(int level, String message) {
      if (level == FATAL || level == ERROR) {
        LOG.error("[JSCH] {}", message);
      } else if (level == WARN) {
        LOG.warn("[JSCH] {}", message);
      } else if (level == INFO) {
        // JSCH is verbose at INFO logging so allow to turn the noise down and log at DEBUG by default
        if (isVerboseLogging()) {
          LOG.info("[JSCH] {}", message);
        } else {
          LOG.debug("[JSCH] {}", message);
        }
      } else {
        LOG.debug("[JSCH] {}", message);
      }
    }
  });
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

private Session createSession(String host, Args args) throws JSchException {
 JSch jsch = new JSch();
 for (String keyFile : getKeyFiles()) {
  jsch.addIdentity(keyFile);
 }
 JSch.setLogger(new LogAdapter());
 Session session = jsch.getSession(args.user, host, args.sshPort);
 session.setConfig("StrictHostKeyChecking", "no");
 return session;
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

private Session createSession(String host, Args args) throws JSchException {
 JSch jsch = new JSch();
 for (String keyFile : getKeyFiles()) {
  jsch.addIdentity(keyFile);
 }
 JSch.setLogger(new LogAdapter());
 Session session = jsch.getSession(args.user, host, args.sshPort);
 session.setConfig("StrictHostKeyChecking", "no");
 return session;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project

@Override
public synchronized void disconnect(boolean force) throws RemoteException {
  if (sftpSession == null) {
    // nothing to do
    LOGGER.log(Level.FINE, "Remote client not created yet => nothing to do");
    return;
  }
  if (!force
      && sftpSession.getServerAliveInterval() > 0) {
    LOGGER.log(Level.FINE, "Keep-alive running and disconnecting not forced -> do nothing");
    return;
  }
  LOGGER.log(Level.FINE, "Remote client trying to disconnect");
  if (sftpSession.isConnected()) {
    LOGGER.log(Level.FINE, "Remote client connected -> disconnecting");
    JSch.setLogger(DEV_NULL_LOGGER);
    sftpSession.disconnect();
    LOGGER.log(Level.FINE, "Remote client disconnected");
  }
  sftpClient = null;
  sftpSession = null;
  sftpLogger.info("QUIT"); // NOI18N
  sftpLogger.info(NbBundle.getMessage(SftpClient.class, "LOG_Goodbye"));
}

代码示例来源:origin: org.apache.gobblin/gobblin-service

@Override
 protected JSch createDefaultJSch(FS fs) throws JSchException {
  if (GitMonitoringService.this.isJschLoggerEnabled) {
   JSch.setLogger(new JschLogger());
  }
  JSch defaultJSch = super.createDefaultJSch(fs);
  defaultJSch.addIdentity(GitMonitoringService.this.privateKeyPath, GitMonitoringService.this.passphrase);
  return defaultJSch;
 }
};

代码示例来源:origin: com.alibaba.middleware/termd-core

public static void init() {
    JSch.setLogger(new JSchLogger());
  }
}

代码示例来源:origin: termd/termd

public static void init() {
    JSch.setLogger(new JSchLogger());
  }
}

代码示例来源:origin: io.termd/termd-core

public static void init() {
    JSch.setLogger(new JSchLogger());
  }
}

代码示例来源:origin: org.onap.appc/appc-netconf-adapter-bundle

@Override
public void connect(NetconfConnectionDetails connectionDetails) throws APPCException {
  String host = connectionDetails.getHost();
  int port = connectionDetails.getPort();
  String username = connectionDetails.getUsername();
  String password = connectionDetails.getPassword();
  try {
    JSch.setLogger(new JSchLogger());
    JSch jsch = new JSch();
    session = jsch.getSession(EncryptionTool.getInstance().decrypt(username), host, port);
    session.setPassword(EncryptionTool.getInstance().decrypt(password));
    session.setConfig("StrictHostKeyChecking", "no");
    Properties additionalProps = connectionDetails.getAdditionalProperties();
    if((additionalProps != null) && !additionalProps.isEmpty()) {
      session.setConfig(additionalProps);
    }
    session.connect(SESSION_CONNECT_TIMEOUT);
    session.setTimeout(10000);
    createConnection(connectionDetails);
  } catch(Exception e) {
    String message = EELFResourceManager.format(Msg.CANNOT_ESTABLISH_CONNECTION, host, String.valueOf(port), username);
    throw new APPCException(message, e);
  }
}

代码示例来源:origin: jcabi/jcabi-ssh

try {
  JSch.setConfig("StrictHostKeyChecking", "no");
  JSch.setLogger(new JschLogger());
  final JSch jsch = new JSch();
  Logger.debug(

代码示例来源:origin: org.apache.ant/ant-jsch

final SSHBase base = this;
if (verbose) {
  JSch.setLogger(new com.jcraft.jsch.Logger() {
    @Override
    public boolean isEnabled(final int level) {

相关文章