JSch read local log file
<p>I am developing a tool that use JSch library to read log files from remote machine for log parsing and some other functionality.  The code to read the log file is given below.  </p>

<pre><code>    JSch jsch=new JSch();
    Session session=jsch.getSession(user, host, 22);
    session.setPassword(password);
    session.setConfig("StrictHostKeyChecking", "no");
    session.connect();

    ChannelSftp sftp = (ChannelSftp) session.openChannel("sftp");
    sftp.connect();

    InputStream stream = null;
    try {
        //this will be changed to execute on a regular time interval
        while (true) {
            stream = sftp.get(rfile);
            read(stream);
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    } finally {
        stream.close();
        sftp.disconnect();
        session.disconnect();
    }
</code></pre>

<p>But, there is a chance that the tool will be deployed to the machine where the log is generated.  So, my question is, </p>

<p>1)  I suspect a performance issue using the <em>sftp.get()</em> as the log file will be read in a regular interval(eg. 5 mins).  Any suggestion to improve performance here ?</p>

<p>2)  whether JSch will have the same network overhead for reading files from the local machine similar to the remote machine.  </p>

<p>3)  If yes, is there any way to improve the performance if the log is reading from a local machine.</p>

<p>May be i can check the ip address of both the target and host machine before reading the log file.  And if both are same i can read the log directly.  But, could there be any better alternative?</p>

<p>Thanks,
nks</p>