dcsimg
Redirect the debug output from JavaMail
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andrew_Cao
Posted On:   Wednesday, October 17, 2001 11:08 PM

How can I redirect the output of session.setDebug(true) so that I can capture it in the program that uses it?

Re: Redirect the debug output from JavaMail

Posted By:   John_Zukowski  
Posted On:   Wednesday, October 17, 2001 11:18 PM

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);
About | Sitemap | Contact