I am creating jsch session to run commands remotely and I am facing a strange behavior. In one of my threads I create session, set output stream to System.err and use the session.
ChannelExec channel = (ChannelExec) session.openChannel("exec");
channel.setErrStream(System.err);
In another thread I have some stuff which uses Java util's logger (which by default writes logs to System.err). Once jsch session is created, I no longer see logger messages in console from my second thread. When I remove this line:
channel.setErrStream(System.err);
or set channel's error stream to null, logger messages from my second thread appear in console just fine.
If jsch session owns System.err stream when setting it, and that's why logger can't use, then what happens when error stream for session is set null? If this is not the case, then why logger messages do not appear after session starts using System.err?
If any one could explain this, that would be very useful.