मैं एक खुद filteroutputstream (आप भी SLF के बजाय org.apache.logging.Logger इस्तेमाल कर सकते हैं)
public class LogStream extends FilterOutputStream
{
private static org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(LogStream.class);
private static final OutputStream bos = new ByteArrayOutputStream();
public LogStream(OutputStream out)
{
// initialize parent with my bytearray (which was never used)
super(bos);
}
@Override
public void flush() throws IOException
{
// this was never called in my test
bos.flush();
if (bos.size() > 0) LOG.info(bos.toString());
bos.reset();
}
@Override
public void write(byte[] b) throws IOException
{
LOG.info(new String(b));
}
@Override
public void write(byte[] b, int off, int len) throws IOException
{
LOG.info(new String(b, off, len));
}
@Override
public void write(int b) throws IOException
{
write(new byte[] { (byte) b });
}
}
बनाया तो मैं अपने उत्पादन
// redirect the output to our logstream
javax.mail.Session def = javax.mail.Session.getDefaultInstance(new Properties());
def.setDebugOut(new PrintStream(new LogStream(null)));
def.setDebug(true);
को javamail कि रीडायरेक्ट किए गए चाल है :)
बस इस पुरानी पोस्ट पर ठोकर खाई। प्रिंटस्ट्रीम डीबग विकल्प का उपयोग किए बिना अब जूल-> slf4j पुल 'java.util.logging.Logger.getLogger ("javax.mail") का उपयोग करने का विकल्प भी है। –