Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to enable logging of com.sibvisions.util.Mail

I have a simple application and on some value changes a workflow is triggered. The workflow sends emails with com.sibvisions.util.Mail class.

My code looks like:

Mail m = new Mail("server", "587", "user", "password");
m.setTLSEnabled(true);
m.setContentType(Mail.CONTENT_HTML);
m.send("from@domain.com", "to@domain.com", "Subject", "Message");

Some users told me that they didn’t receive an email. I want to find out if the problem is in my application. So, how is it possible to log mail transport?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I know that it’s possible to add my own log output before m.send(...) but this doesn’t log the mail transport.

>Solution :

Mail transport logging is not related to JVx because it just uses Java Mail API. To enable logging, just configure the log level of:

com.sun.mail.level = ALL

This log level logs all mail transports. The API documentation contains logger information at the end of package summaries, e.g.

https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html

Just put your log definition in your logging.properties and JVx will read this automatically. It’s also possible to set the log level programmatically:

LoggerFactory.getInstance("com.sun.mail").setLevel(LogLevel.ALL);

But I recommend using logging.properties file.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading