asp.netsmtpenterprise-librarylogging-application-block

How do I specify the Username / Password for my SMTP in the Email Trace Listener used by the MS Entriprise Library Logging Block?


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="my@email.com" fromAddress="my@email.com"
        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?


Solution

  • Justin, we've added authentication to the EmailTraceListener in v5.0. If you must stay on 4.1, see the workarounds here.