jvx

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?

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.