How can I redirect the output of session.setDebug(true) so that I can capture it in the program that uses it?
Created May 7, 2012
John Zukowski The messages are hardcoded to go to System.out. The best you can do is redirect System.out to a ByteArrayOutputStream:
session.setDebug(true); ByteArrayOutputStream os = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(os); // save output PrintStream old = System.out; // change output System.setOut(ps); // send ... // reset output System.setOut(old); System.out.println(os);