java.util.logging.Logger.log output disappear

Help
2011-01-28
2013-05-28
  • 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.

    I've logged this problem as a bug; you can find the code of
    Exec.java with log statements added, there as attachment.

    If I dig a little deeper, and add Logger.log statements to
    relevant parts of
      Channel.java
    and
      IO.java
    I see that after IO.out_ext.close() no more log messages
    appear.

    Does anybody know how to fix this?

     
  • 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;
    )