I am using log4j to send an email when there is an exception. below is my log4j properties file configuration.
log4j.rootLogger=WARN, R, email
log4j.
appender.R=org.apache.log4j.ConsoleAppender
log4j.
appender.R.layout=org.apache.log4j.PatternLayout
log4j.
appender.R.layout.ConversionPattern=%d{HH:mm:ss} %-5p [%c{1}]: %m%n
log4j.
appender.email=org.apache.log4j.net.SMTPAppender
log4j.
appender.email.BufferSize=10
log4j.
appender.email.SMTPHost=myhost.com
log4j.
appender[email protected]
log4j.
appender[email protected]
log4j.
appender.email.Subject=Error
log4j.
appender.email.layout=org.apache.log4j.PatternLayout
mine is maven project i have added dependencies for mail.jar, activation.jar and smtp.jar. But on application server startup itself i get below error:
[ERROR] log4j:ERROR Error occured while sending e-mail notification.
[ERROR] javax.mail.NoSuchProviderException: smtp
[ERROR] at javax.mail.Session.getService(Session.java:782)
[ERROR] at javax.mail.Session.getTransport(Session.java:708)
[ERROR] at javax.mail.Session.getTransport(Session.java:651)
[ERROR] at javax.mail.Session.getTransport(Session.java:631)
[ERROR] at javax.mail.Session.getTransport(Session.java:686)
[ERROR] at javax.mail.Transport.send0(Transport.java:166)
Am i missing any thing here? What is the root cause of the error? is it because of incorrect SMTP host name? or is it because of any missing/conflicting dependencies?