【问题标题】:Email only Errors/Warnings with Microsoft Logging Application Block 3.1.0.0Microsoft Logging Application Block 3.1.0.0 仅通过电子邮件发送错误/警告
【发布时间】:2010-07-27 21:32:32
【问题描述】:

我做错了什么?

我正在尝试配置日志记录设置以在数据库和事件查看器中记录所有事件,但仅通过电子邮件发送错误和警告。数据库和事件查看器部分工作正常,除了我没有收到任何关于错误的电子邮件。我错过了什么吗?

注意:没有任何问题 smtp 设置,因为我得到了事件的 如果我将听众添加到电子邮件 类别中的“常规”和“所有事件” 来源。

这是我的配置:(我使用的是 Microsoft.Practices.EnterpriseLibrary.Logging 3.1.0.0)

    <loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="false">
    <listeners>
      <add databaseInstanceName="LOGGING_DB" writeLogStoredProcName="WriteLog"
              addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
              listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
              traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
              name="Database Trace Listener" />

      <add toAddress="jafet@jafet.com" fromAddress="jafet@jafet.com" subjectLineStarter="My App" subjectLineEnder="QA" smtpServer="SMTP1.jafet.com" smtpPort="25" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="Email TraceListener"/>
      <add source="My Application" formatter="Text Formatter" log="" machineName="." listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="Event Log Destination"/>
    </listeners>
    <formatters>
      <add template="Timestamp: {timestamp}&#xA;Message: {message}&#xA;Category: {category}&#xA;Priority: {priority}&#xA;EventId: {eventid}&#xA;Severity: {severity}&#xA;Title:{title}&#xA;Machine: {machine}&#xA;Application Domain: {appDomain}&#xA;Process Id: {processId}&#xA;Process Name: {processName}&#xA;Win32 Thread Id: {win32ThreadId}&#xA;Thread Name: {threadName}&#xA;Extended Properties: {dictionary({key} - {value}&#xA;)}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="Text Formatter"/>
    </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="Event Log Destination"/>
          <add name="Database Trace Listener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events">
        <listeners>
          <add name="Event Log Destination"/>
          <add name="Database Trace Listener" />
        </listeners>
      </allEvents>
      <notProcessed switchValue="All" name="Unprocessed Category"/>
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Database Trace Listener" />
          <add name="Event Log Destination"/>
          <add name="Email TraceListener"/>
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>

【问题讨论】:

    标签: c# asp.net logging enterprise-library


    【解决方案1】:

    我知道这个回复很晚了……

    我也遇到了同样的问题。我刚刚在这里 (http://www.thejoyofcode.com/Log_Event_to_Listener_Routing_in_Enterprise_Library.aspx) 读到错误和警告的特殊来源是针对内部日志记录错误,例如,如果记录器由于数据库连接断开而无法登录到数据库.. 如果您想记录您的应用程序错误,请创建一个单独的类别并登录到那里。

    干杯, 马赫什

    【讨论】:

      猜你喜欢
      • 2016-12-28
      • 2013-11-12
      • 1970-01-01
      • 2012-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 2011-12-09
      相关资源
      最近更新 更多