Email only Errors/Warnings with Logging 3.1.0.0

Topics: Logging Application Block
Jul 27, 2010 at 4:28 PM

Hello,

What am I doing wrong?

I'm trying to configure the logging settings to log all events in a database and event viewer  but email only errors and warnings.  Database and Event Viewer part works fine except that I'm not getting any email for errors. Am I missing something?

Here is my config:  (I'm using 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>

Thanks in advance

Jafet

Jul 28, 2010 at 1:53 AM

Do you have access to the SMTP server?  If yes and you have permission to configure it, could you try out the steps mentioned here?

Another thing, does your SMTP server require authentication? The EntLib 3.1 version of EmailTraceListener doesn't support this (EntLib 5.0 does).  

But as a workaround, you can use the application or machine configuration files to specify the default host, port, and credential values for all SmtpClient objects by configuring the mailSettings element.

If you do not like this approach you can use the authenticated email trace listener which can be downloaded here.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com