I'm using Java 11 (Corretto 11), log4j 2.12.1, and jakarta.mail 2.0.1. My log4j configuration is using the SMTP appender, but I'm not receiving any emails. I do see the log statements in the file (when using the File or Console appenders). And also when using the exact same log4j config with Java 8, log4j 2.12.1, and javax.mail 1.6.2, I did receive emails. I can't use both javax.mail and jakarta.mail since there are overlapping classes (such as com.sun.mail.util.MimeUtil
). It does work with javax.mail 1.6.2.
What is the recommendation for Java 11 log4j2 SMTP Appender? Am I stuck with using the older javax.mail 1.6.2 that's no longer maintained if I want to use log4j?
This may be a quirk in Eclipse, but when I look at the source of org.apache.logging.log4j.core.net.MimeMessageBuilder
from log4j 2.12.1, the imports show javax.mail.*
, but the javadoc for the MimeMessage
class shows jakarta.mail.internet.MimeMessage
.
CodePudding user response:
As you are probably aware, the transfer of Java EE from Oracle to the Eclipse Foundation required a change from the javax.*
namespace (in Java EE 8/Jakarta EE 8) to the jakarta.*
namespace (Jakarta EE 9).
Since many years may pass until all libraries switch to Jakarta EE 9 and considering the fact that the switch must be done simultaneously for all Jakarta EE 9 technologies, Jakarta EE 8 implementations will probably get updates for a very long time.
Since Log4j is one of those libraries that did not migrate yet, use the jakarta.mail
artifact, version 1.6.x from the com.sun.mail
group. As you can see it still gets updates (latest version today: 1.6.7).