当使用 NLog 作为日志记录工具时,我们可以轻松地通过电子邮件发送消息,例如,这是使用 Gmail 作为 smtp 服务器的示例配置:
<targets>
<target name="gmail" type="Mail"
smtpServer="smtp.gmail.com"
smtpPort="587"
smtpAuthentication="Basic"
smtpUsername="[email protected] /cdn-cgi/l/email-protection"
smtpPassword="password"
enableSsl="true"
from="[email protected] /cdn-cgi/l/email-protection"
to="[email protected] /cdn-cgi/l/email-protection"
cc="[email protected] /cdn-cgi/l/email-protection;[email protected] /cdn-cgi/l/email-protection;[email protected] /cdn-cgi/l/email-protection"
/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="gmail" />
</rules>
它就像一个魅力。
但在上面的示例中,密码以纯文本形式放入配置文件中。
有没有办法以某种方式保护它?
是的,您可以将 NLog.config(如果此文件中有)移至您的 app.config,然后加密您的 app.config。
您可以看到如何加密app.confighere http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/08153cf1-41b6-4472-875b-803f0845a4e1/.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)