如何在 MS Entririse Library 日志记录块使用的电子邮件跟踪侦听器中指定 SMTP 的用户名/密码?
我正在使用 Enterprise Library 4.1,并且已配置日志记录应用程序块以在 ASP.NET MVC 3 应用程序中记录错误。一切工作正常,我的错误目前已写入日志。
我还想通过电子邮件将错误信息发送给自己,但我们使用 Google Apps,其 SMTP 服务器需要用户名/密码。
这是我为电子邮件日志记录添加的侦听器,我希望我只需要添加某种 username="" 和 password="" 属性。有人知道它们是什么吗?
<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add toAddress="[email protected]" fromAddress="[email protected]"
subjectLineStarter="" subjectLineEnder="" smtpServer="smtp.gmail.com"
smtpPort="587" formatter="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Email" />
</listeners>
我应该注意到,它看起来是谎言 EmailTraceListnerData 在 Enterpise Library 5.0 中确实有一个“userName”和“password”属性 http://msdn.microsoft.com/en-us/library/ee762316(v=PandP.50).aspx。但似乎不适用于4.1。有人知道解决方法吗?
I'm using Enterprise Library 4.1 and I've configured the Logging Application Block to log my errors in my ASP.NET MVC 3 application. Everything works just fine and my errors are currently written to a log.
I'd like to also email the errors to myself but we use Google Apps and its SMTP server requires a username / password.
Here's the listener I've added for Email logging I'm hoping I just need to add some kind of username="" and password="" attributes. Anybody know what they are?
<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add toAddress="[email protected]" fromAddress="[email protected]"
subjectLineStarter="" subjectLineEnder="" smtpServer="smtp.gmail.com"
smtpPort="587" formatter="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Email" />
</listeners>
I should note that it looks lie EmailTraceListnerData does have a "userName" and "password" property in Enterpise Library 5.0 http://msdn.microsoft.com/en-us/library/ee762316(v=PandP.50).aspx. But it doesn't seem to apply to 4.1. Anybody know a workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Justin,我们在 v5.0 中向 EmailTraceListener 添加了身份验证。如果您必须保留在 4.1 上,请参阅此处的解决方法。
Justin, we've added authentication to the EmailTraceListener in v5.0. If you must stay on 4.1, see the workarounds here.