Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enterprise Library: Logging Block and Email

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

Jack

like image 520
Jack Avatar asked Mar 09 '09 18:03

Jack


People also ask

What is Enterprise Library Logging?

The Enterprise Library Logging Application Block simplifies logging to various destinations (file, database, event log, MSMQ etc.) and tracing.

How do I open Microsoft Enterprise Library console?

On the taskbar, click Start, point to All Programs, point to Microsoft patterns & practices, point to Enterprise Library 5.0, point to Enterprise Library Configuration, and then select the version of the configuration editor you require.

What is the use of Microsoft Enterprise Library?

Microsoft Enterprise Library is a collection of reusable application blocks designed to assist software developers with common enterprise development challenges.


1 Answers

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

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="[email protected]" fromAddress="[email protected]"
        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>

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

like image 146
tentonipete Avatar answered Oct 08 '22 14:10

tentonipete