使用NLog时保护电子邮件密码 [英] Protecting an email password when using NLog

查看:210
本文介绍了使用NLog时保护电子邮件密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用NLog作为测井仪器时,我们可以通过电子邮件轻松发送消息,例如,这是使用Gmail作为smtp服务器的示例配置:

When using NLog as a logging instrument we can easily send messages via email, for example this is the example configuration for using Gmail as a smtp server:

<targets>
<target name="gmail" type="Mail"
        smtpServer="smtp.gmail.com"
        smtpPort="587"
        smtpAuthentication="Basic"
        smtpUsername="user@gmail.com"
        smtpPassword="password"
        enableSsl="true"
        from="emailaddress@gmail.com"
        to="recipient@example.com"
        cc="alice@example.com;bob@example.com;charlie@example.com"
      />
</targets>
<rules>
 <logger name="*" minlevel="Debug" writeTo="gmail" />
</rules>

它的作用就像一个魅力。
但是在上面的例子中,密码在配置文件中以纯文本形式显示。

有没有办法保护它?

It works like a charm. But in the above example the password is put in plain text in a configuration file.
Is there a way to protect it somehow?

推荐答案

是的,您可以移动NLog.config(如果您在此文件中有)到您的app.config,然后加密您的app.config。

Yes, you can move the NLog.config (If you have it in this file) to your app.config and then encrypt you app.config.

您可以看到如何加密app.config 这里

You can see how to encrypt the app.config here.

这篇关于使用NLog时保护电子邮件密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆