Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#51 java.util.logging.Logger.log output disappears

closed-fixed
nobody
None
5
6 days ago
2011-01-28
No

I'm writing an application where I use
java.util.logging.Logger.log(Level,String)
in all my source code.

I'm now using JSch 0.1.44 for SSH functionality, and find that beyond a
certain point in my program, the output from Logger.log(Level,String) no
longer is shown.

I've reproduced this problem in the example program
Exec.java
provided with JSch.
I added calls to
java.util.logging.Logger.log(Level,String)
and see that somewhere between
channel.connect()
channel.disconnect()
all output from java.util.logging.Logger.log disappears.

The code for Exec.java is attached.
It produces output:
28-jan-2011 11:43:58 nl.redheadtech.ssh.Exec log
INFO: before new JSch()
28-jan-2011 11:43:58 nl.redheadtech.ssh.Exec log
INFO: after new JSch()
28-jan-2011 11:44:07 nl.redheadtech.ssh.Exec log
INFO: before getSession(...)
28-jan-2011 11:44:07 nl.redheadtech.ssh.Exec log
INFO: after getSession(...)
28-jan-2011 11:44:07 nl.redheadtech.ssh.Exec log
INFO: before connect()
28-jan-2011 11:44:24 nl.redheadtech.ssh.Exec log
INFO: after connect()
28-jan-2011 11:44:26 nl.redheadtech.ssh.Exec log
INFO: before openChannel(...)
28-jan-2011 11:44:26 nl.redheadtech.ssh.Exec log
INFO: after openChannel(...)
28-jan-2011 11:44:26 nl.redheadtech.ssh.Exec log
INFO: before channel.connect()
28-jan-2011 11:44:26 nl.redheadtech.ssh.Exec log
INFO: after channel.connect()
BASH_EXECUTION_STRING='set|grep SSH'
SSH_CLIENT='89.184.189.118 61199 22'
SSH_CONNECTION='89.184.189.118 61199 62.21.129.231 22'
exit-status: 0

Discussion

  • Exec.java with log statements added.

     
    Attachments
  • The cause of the problem is in Exec.java :
    ((ChannelExec) channel).setErrStream(System.err);

    The solution is simple:
    boolean dontClose = true;
    ((ChannelExec) channel).setErrStream(System.err, dontClose);

    The reason that this is needed, is that without dontClose true, in
    session.disconnect()
    the output stream passed to setErrStream() will be closed .

    (The session stores this output stream in
    io.out_ext
    where io is a private instance variable of Session:
    private IO io;
    )

     
    • status: open --> closed-fixed