我正在尝试将 log4j 配置为使用 SMTPAppender
,但我不断收到中继访问被拒绝错误.在我的笔记本电脑上和直接从我的共享托管环境中执行我的代码时,我收到了这个错误.
I'm trying to configure log4j to use the SMTPAppender
but I keep getting relay access denied errors. I get this error when executing my code on my laptop AND straight from my shared hosting environment.
以下是相关配置:
#CONFIGURE SMTP
log4j.appender.email=org.apache.log4j.net.SMTPAppender
log4j.appender.email.SMTPHost=mydomain.com
log4j.appender.email.SMTPUsername=myuser
log4j.appender.email.SMTPPassword=mypw
log4j.appender.email.From=myuser@mydomain.com
log4j.appender.email.BufferSize=1
log4j.appender.email.EvaluatorClass=TriggerLogEvent
log4j.appender.email.layout=org.apache.log4j.PatternLayout
log4j.appender.email.layout.ConversionPattern=%m
如果我改用 log4j.appender.email.SMTPHost=mail.mydomain.com
,则会收到身份验证错误.如果有人使用 DreamHost 电子邮件帐户设置了 log4j SMTPAppender
,我的主机是在 DreamHost 上的.
If I switch to log4j.appender.email.SMTPHost=mail.mydomain.com
instead then I get authentication errors. My hosting is on DreamHost so bonus points if anyone has set up log4j SMTPAppender
using a DreamHost email account.
原来我只是把属性都弄错了.应该是:
Turns out I just had the properties all wrong. Should be:
#CONFIGURE SMTP
log4j.appender.email=org.apache.log4j.net.SMTPAppender
log4j.appender.email.SMTPHost=mail.mydomain.com
log4j.appender.email.SMTPUsername=myuser@mydomain.com
log4j.appender.email.SMTPPassword=mypw
log4j.appender.email.From=myuser@mydomain.com
log4j.appender.email.BufferSize=1
log4j.appender.email.EvaluatorClass=TriggerLogEvent
log4j.appender.email.layout=org.apache.log4j.PatternLayout
log4j.appender.email.layout.ConversionPattern=%m
这篇关于在 log4j 中配置 SMTPAppender 的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!