带Gmail的Log4Net SMTP Appender

历览千载书,时时见遗烈。这篇文章主要讲述带Gmail的Log4Net SMTP Appender相关的知识,希望能为你提供帮助。
我正在使用此代码。虽然我启用了Log4Net调试,但它没有错误。我也没有收到电子邮件。有任何想法吗?
我替换了登录凭据,并使用占位符替换了/。

< appender name="SmtpAppender" type="log4net.Appender.SmtpAppender"> < authentication value="https://www.songbingjia.com/android/Basic" /> < to value="https://www.songbingjia.com/android/to" /> < from value="https://www.songbingjia.com/android/from" /> < subject value="https://www.songbingjia.com/android/Log message" /> < username value="https://www.songbingjia.com/android/myusername" /> < password value="https://www.songbingjia.com/android/mypass" /> < smtpHost value="https://www.songbingjia.com/android/smtp.gmail.com" /> < port value="https://www.songbingjia.com/android/587"/> < bufferSize value="https://www.songbingjia.com/android/1" /> < EnableSsl value="https://www.songbingjia.com/android/true"/> < lossy value="https://www.songbingjia.com/android/true" /> < threshold value="https://www.songbingjia.com/android/FATAL"/> < layout type="log4net.Layout.PatternLayout"> < conversionPattern value="https://www.songbingjia.com/android/%date{ABSOLUTE} [%logger]%newlineUsername: %property{username}%newline%level - %message%newline%exception" /> < /layout> < /appender>

答案我知道它已经晚了但是更换了
< threshold value="https://www.songbingjia.com/android/FATAL"/>


< evaluator type="log4net.Core.LevelEvaluator"> < threshold value="https://www.songbingjia.com/android/ERROR" /> < /evaluator>

另一答案我建议将以下内容放入appSettings节点。
< appSettings> < add key="log4net.Internal.Debug" value="https://www.songbingjia.com/android/true"/> < /appSettings>

【带Gmail的Log4Net SMTP Appender】然后它将输出诊断信息,例如
log4net: Setting Property [From] to String value [tomas@kodi.is] log4net: Setting Property [Subject] to String value [Kodiak OMS Shortcode service] log4net: Setting Property [SmtpHost] to String value [mail.sip.is] log4net: Setting Property [Port] to Int32 value [25] log4net: Setting Property [BufferSize] to Int32 value [1] log4net: Setting Property [EnableSsl] to Boolean value [True] log4net: Setting Property [Threshold] to Level value [DEBUG] log4net: Setting Property [Lossy] to Boolean value [False] log4net: Converter [message] Option [] Format[min=-1,max=2147483647,leftAlign=False] log4net: Converter [newline] Option [] Format [min=-1,max=2147483647,leftAlign=False] log4net: Setting Property [ConversionPattern] to String value [%utcdate [%level] - %message%newline%exception] log4net: Converter [utcdate] Option [] Format [min=-1,max=2147483647,leftAlign=False] log4net: Converter [literal] Option [ [] Format [min=-1,max=2147483647,leftAlign=False] log4net: Converter [level] Option [] Format [min=-1,max=2147483647,leftAlign=False] log4net: Converter [literal] Option [] - ] Format [min=-1,max=2147483647,leftAlign=False] log4net: Converter [message] Option [] Format [min=-1,max=2147483647,leftAlign=False] log4net: Converter [newline] Option [] Format [min=-1,max=2147483647,leftAlign=False] log4net: Converter [exception] Option [] Format [min=-1,max=2147483647,leftAlign=False] log4net: Setting Property [Layout] to object [log4net.Layout.PatternLayout] log4net: Created Appender [EmailLog] log4net: Adding appender named [EmailLog] to logger [EmailLogger]. log4net: Hierarchy Threshold [] log4net:ERROR [SmtpAppender] ErrorCode: GenericFailure. Error occurred while sending e-mail notification. System.Net.Mail.SmtpException: Server does not support secure connections. at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) at log4net.Appender.SmtpAppender.SendEmail(String messageBody) at log4net.Appender.SmtpAppender.SendBuffer(LoggingEvent[] events)


    推荐阅读