I'm trying to set up some console applications to use the Enterprise Library 5 Logging Block.
I've defined the necessary elements in my app.config file and I know they work because the Event Log trace listener is working correctly. The issue is with my email trace listeners. Essentially I'd rather it make use of the configuration\system.net\mailSettings\smtp
configuration section rather than individually configuring the multiple email listeners (also so I can have the DEBUG version "sending" emails to a local directory rather than an actual email). My configuration looks something like this:
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
<add name="Email Trace Listener"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
toAddress="some@address"
fromAddress="some@address"
subjectLineStarter="APPLICATION -- "
subjectLineEnder=" -- Release"
filter="Information"
formatter="Text Formatter" />
<add name="Informational Email"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
toAddress="some@address"
fromAddress="some@address"
subjectLineStarter="APPLICATION -- "
subjectLineEnder=" -- Release"
formatter="Minimalist Text Formatter" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}"
name="Text Formatter" />
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="Timestamp: {timestamp}{newline}
Title:{title}{newline}
Message: {message}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}"
name="Minimalist Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Event Log Listener" />
<add name="Email Trace Listener" />
</listeners>
</add>
<add switchValue="Information" name="Email">
<listeners>
<add name="Informational Email" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category">
<listeners>
<add name="Event Log Listener" />
</listeners>
</notProcessed>
<errors switchValue="Error" name="Logging Errors & Warnings">
<listeners>
<add name="Email Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="valid.local.SMTP.server"/>
<specifiedPickupDirectory pickupDirectoryLocation="C:\Temp"/>
</smtp>
</mailSettings>
</system.net>
</configuration>
When I change deliveryMethod="Network"
to deliveryMethod=SpecifiedPickupDirectory
all the emails are written out to the configured directory as expected. But when it's set to Network no emails are sent out.
I verified with a web application that we have set up nearly identically that it works with the Network configuration just fine. I'm not seeing any additional event log messages about not being able to send emails (either it really isn't being logged, or it's being swallowed...). I'm at a loss for the next steps to get this working. Has anybody else ran into this issue?