以下 jar 文件保存在 lib 文件夹 tomcat-juli-adapter.jar、java-mail-1.4.4.jar、log4j-1.2.16.jar、smtp-1.4.4jar 中。和 bin 文件夹中的 tomcat-juli.jar。我能够看到 catalina 以及 localhost 日志,但无法接收来自 smtp 服务器的电子邮件。我已将 smtp.debug 设置为 true 但没有用。请帮助我,我是初学者,我在过去两周内尝试并接受了这个
下面是我的代码
log4j.rootLogger = INFO, CONSOLE,CATALINA,LOCALHOST,mail
# Define all the appenders
log4j.appender.CATALINA = org.apache.log4j.DailyRollingFileAppender
log4j.appender.CATALINA.File = ${catalina.base}/logs/catalina.log
log4j.appender.CATALINA.Append = true
log4j.appender.CATALINA.Encoding = UTF-8
# Roll-over the log once per day
log4j.appender.CATALINA.DatePattern = '.'yyyy-MM-dd
log4j.appender.CATALINA.layout = org.apache.log4j.EnhancedPatternLayout
log4j.appender.CATALINA.layout.ConversionPattern = %d{dd MMM yyyy HH:mm:ss}{GMT+0} [%t] %-5p %c- %m%n
log4j.appender.LOCALHOST = org.apache.log4j.DailyRollingFileAppender
log4j.appender.LOCALHOST.File = ${catalina.base}/logs/localhost.log
log4j.appender.LOCALHOST.Append = true
log4j.appender.LOCALHOST.Encoding = UTF-8
log4j.appender.LOCALHOST.DatePattern = '.'yyyy-MM-dd
log4j.appender.LOCALHOST.layout = org.apache.log4j.EnhancedPatternLayout
log4j.appender.LOCALHOST.layout.ConversionPattern = %d{dd MMM yyyy HH:mm:ss}{GMT+0} [%t] %-5p %c- %m%n
log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Encoding = UTF-8
log4j.appender.CONSOLE.layout = org.apache.log4j.EnhancedPatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern = %d{dd MMM yyyy HH:mm:ss}{GMT+0} [%t] %-5p %c- %m%n
log4j.appender.mail=org.apache.log4j.net.SMTPAppender
log4j.appender.mail.BufferSize=4096
log4j.appender.mail.SMTPHost=smtp.gmail.com
log4j.appender.mail.SMTPPort=587
log4j.appender.mail.SMTPProtocol=smtp
log4j.appender.mail.smtp.starttls.enable=true
log4j.appender.mail.SMTPUsername=xxxxxxxx
log4j.appender.mail.SMTPPassword=xxxxxxx
log4j.appender.mail.Subject=Application Error
log4j.appender.mail.Threshold=ERROR
log4j.appender.mail.From=xxxxxxxxxx
log4j.appender.mail.To=xxxxxxxx
log4j.appender.mail.layout = org.apache.log4j.PatternLayout
log4j.appender.mail.layout.ConversionPattern=%d %p [%c] - <%m>%n
log4j.appender.mail.SMTPDebug=true
log4j.appender.mail.filter.1=org.apache.log4j.varia.LevelRangeFilter
log4j.appender.mail.filter.1.LevelMin=INFO
log4j.appender.mail.filter.1.LevelMax=ERROR
log4j.appender.mail.filter.2=org.apache.log4j.varia.DenyAllFilter