企业库:记录块和电子邮件 [英] Enterprise Library: Logging Block and Email

查看:76
本文介绍了企业库:记录块和电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何使用日志记录块发送错误电子邮件的教程链接或示例吗?

Does anyone have a tutorial link or an example on how to use the Logging block to send out error email?

Jack

推荐答案

您需要在Logging Application Block中设置EmailTraceListener。

You need to set up an EmailTraceListener in the Logging Application Block.

您可以使用企业库用户界面,但web.config部分最终看起来像这样:

You can use the Enterprise Library UI but the web.config section ends up looking something like this:

<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="Default" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add toAddress="admin@company.com" fromAddress="fromemail@company.com"
        subjectLineStarter="" subjectLineEnder="" smtpServer="127.0.0.1"
        smtpPort="25" 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>
    <categorySources>
      <add switchValue="All" name="Default">
        <listeners>
          <add name="Email" />
        </listeners>
      </add>    
    </categorySources>
</loggingConfiguration>

这将在您正确设置SMTP服务器的情况下起作用。您可以使用Telnet通过发送命令行电子邮件进行检查。

This will work providing your SMTP server is set up correctly. You can use Telnet to check that by sending command line email.

这篇关于企业库:记录块和电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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