Enterprise Library 4.1 Exception handling not working on server 2008

Topics: Exception Handling Application Block, Logging Application Block
Apr 8, 2010 at 4:14 PM
Edited Apr 8, 2010 at 4:42 PM

I am new to Enterprise Library 4.1,exception handling application block working fine (flatfile and email) on my local system, but not working on windowsserver 2008, where as logging application block  working fine even on windowsserver 2008.Both are using same folder for writing the flat file.Please help   

Local(development) System:WindowsXp,IIS V5.1

Server: Windows server 2008 R2, IIS7

.Here's my code  

  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add toAddress="given valid data"
        fromAddress="given valid data" subjectLineStarter="" subjectLineEnder=""
        smtpServer="given valid data" smtpPort="25" formatter="Text Logging 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 TraceListener" />
      <add fileName="ErrorLog\PMS-ErrorLog.log" footer="----------------END------------------------"
        formatter="Error Text Formatter" header="----------------START------------------------"
        rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="0"
        timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Error Flat File Trace Listener" />
      <add source="Enterprise Library Logging" formatter="Logging Errors Text Formatter"
        log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Formatted EventLog TraceListener" />
      <add fileName="ErrorLog\PMS-DefaultLogError.log" footer="----------------END------------------------"
        formatter="" header="----------------START------------------------"
        rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="0"
        timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Logging Errors Flat File Trace Listener" />
      <add fileName="ErrorLog\PMS-Logger.log" footer="---------------- END ------------------------"
        formatter="Text Logging Formatter" header="---------------- START ------------------------"
        rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="0"
        timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Rolling Flat File Trace Listener" />
      <add fileName="ErrorLog\PMS-SqlInjection.log" footer="-------------------END---------------------"
        formatter="" header="-------------------START---------------------"
        rollFileExistsBehavior="Increment" rollInterval="None" rollSizeKB="0"
        timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Sql Injection Flat File Trace Listener" />
    </listeners>
    <formatters>
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Error Text Formatter" />
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Logging Errors Text Formatter" />
      <add template="{timestamp}&#xD;&#xA;&#xD;&#xA;{message}&#xD;&#xA;"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Sql Injection Text Formatter" />
      <add template="{machine} : {timestamp} : {category}&#xD;&#xA;&#xD;&#xA;{title}&#xD;&#xA;&#xD;&#xA;{message}"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Text Logging Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="Error">
        <listeners>
          <add name="Email TraceListener" />
          <add name="Error Flat File Trace Listener" />
          <add name="Formatted EventLog TraceListener" />
          <add name="Logging Errors Flat File Trace Listener" />
        </listeners>
      </add>
      <add switchValue="All" name="General">
        <listeners>
          <add name="Rolling Flat File Trace Listener" />
        </listeners>
      </add>
      <add switchValue="All" name="SQLInjection">
        <listeners>
          <add name="Sql Injection Flat File Trace Listener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Logging Errors Flat File Trace Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="LogAndPropogateException Policy">
        <exceptionTypes>
          <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="NotifyRethrow" name="Exception">
            <exceptionHandlers>
              <add logCategory="Error" eventId="100" severity="Error" title="Enterprise Library Exception Handling"
                formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                priority="0" useDefaultLogger="false" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="Exception Logging Handler" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
      <add name="Wrap Policy">
        <exceptionTypes>
          <add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="ThrowNewException" name="Exception">
            <exceptionHandlers>
              <add exceptionMessage="Bad server error" exceptionMessageResourceType=""
                exceptionMessageResourceName="" wrapExceptionType="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WrapHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="Wrap Handler" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>

Event log trace listener in the Errors & warning section of the logging application block generated this error.

Logging Errors & Warnings Error: 6352 : Timestamp: 07.04.2010 14:57:25
Message: Tracing to LogSource 'Error' failed. Processing for other sources will continue.

See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks.


Summary for Enterprise Library Distributor Service:
======================================
-->

Message:
Timestamp: 07.04.2010 14:57:18
Message: HandlingInstanceID: 64ac909e-980e-420b-9f2c-24824242b789
An exception of type 'System.FormatException' occurred and was caught.

Apr 12, 2010 at 1:08 AM

Just to confirm, logging to flat file works on windows 2008 but when used in an exception handler, it doesn't?  Is this correct?  In your Error category, does the email and formatted event log trace listener generates the expected log and only the flat file doesn't?  Or both email and the flat file?

Please also post the stack trace included  in the logged error.

 

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

Apr 13, 2010 at 7:21 AM

Hi Sarah,

Yes,Logging to flatfile using exception handler is not working.Both flatfile and Email are not working on server(Note:Both working fine on development machine).Here's the total stack trace logged

Logging Errors & Warnings Error: 6352 : Timestamp: 07.04.2010 12:18:14
Message: Tracing to LogSource 'Error' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks.


Summary for Enterprise Library Distributor Service:
======================================
--> 
Message: 
Timestamp: 07.04.2010 12:18:07
Message: HandlingInstanceID: 15005271-6c72-4031-bf9c-1d37ab8ed16b
An exception of type 'System.FormatException' occurred and was caught.
----------------------------------------------------------------------
04/07/2010 14:18:07
Type : System.FormatException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Die Zeichenfolge wurde nicht als gültiges DateTime erkannt.
Source :Core.DAL
Help link : 
Data : System.Collections.ListDictionaryInternal
TargetSite : System.DateTime GetPersonLastOrderDate(Int64)
Stack Trace :    bei Core.DAL.Implementation.WebShopperRepositoryDAL.GetPersonLastOrderDate(Int64 PersonCode)
   bei Core.DAL.Implementation.WebShopperRepositoryDAL.PopulateWebUserDtls(WebShopper Shopper, IWebUser objuser)
   bei Core.BAL.Implementation.WebShopperRepositoryBAL.PopulateWebUser(WebShopper Shopper, IWebUser webUser)
   bei 
Web.PMS.TestSite.common.PopulateMiniWebShopperSession(WebShopper Shopper)
   bei Web.PMS.TestSite.Cartservice.ValidateLogin(String Email, String Password, String Rating, String strFrom)


Exception Information Details:
======================================
Exception Type: System.Net.Mail.SmtpFailedRecipientsException
InnerExceptions: System.Net.Mail.SmtpFailedRecipientException[]
FailedRecipient: 
StatusCode: GeneralFailure
Message: Senden an alle Empfänger nicht möglich.
Data: System.Collections.ListDictionaryInternal
TargetSite: System.Net.Mail.MailWriter SendMail(System.Net.Mail.MailAddress, System.Net.Mail.MailAddressCollection, System.String, System.Net.Mail.SmtpFailedRecipientException ByRef)
HelpLink: NULL
Source: System

StackTrace Information Details: 
======================================
   bei System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
   bei System.Net.Mail.SmtpClient.Send(MailMessage message)
   bei Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailMessage.SendMessage(MailMessage message)
   bei Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailMessage.Send()
   bei Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data)
   bei Microsoft.Practices.EnterpriseLibrary.Logging.LogSource.TraceData(TraceEventType eventType, Int32 id, LogEntry logEntry, TraceListenerFilter traceListenerFilter)
   bei Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter.ProcessLog(LogEntry log)

Exception Information Details:
======================================
Exception Type: System.Net.Mail.SmtpFailedRecipientException
FailedRecipient: 
StatusCode: MailboxUnavailable
Message: Postfach nicht verfügbar. Die Serverantwort war: 5.7.1 Unable to relay for 
Data: System.Collections.ListDictionaryInternal
TargetSite: NULL
HelpLink: NULL
Source: NULL
Category: 
Priority: -1
EventId: 6352
Severity: Error
Apr 13, 2010 at 7:43 AM

The FormatException is what you're trying to handle and log, am I right?  The SmtpFailedRecipientException seems to be related to the settings of your mail server.  Try following the steps mentioned here if you have the option to : http://entlib.codeplex.com/Thread/View.aspx?ThreadId=85715

 

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

Apr 13, 2010 at 1:30 PM

Hi Sarah,

My requirement is not limited to any specific exception(i would like to log all exceptions through flat file and email) ,it's general to all types of exceptions.

As per my web.config,I am handling all system exceptions (System.Exception,no categorization done) under Category Sources>Error ,Under which i am using flatfile and email methods for exception logging .

Flat file & email are not working.I have copied stack trace from the file which it had created under  Special sources>Logging Errors & Warnings(which is a default one).But i think this is not the actual

functionality that it should work .

 

Thanks,

Jayanthi

Apr 14, 2010 at 12:35 AM

Yes, I understand that, I was just asking if the FormatException is the exception that you're trying to log and not the exception that occurred inside the Logging Application Block.  I'm sure the smtpfailedrecipientexception occurred inside LAB, I wasn't just clear in the case of FormatException but its stack trace shows that it's thrown from your app so I was just confirming.  Did you try out the steps in the link I gave above?

Another thing, the log you posted came from the ErrorLog\PMS-DefaultLogError.log file, right?  Could you change your listener under the Logging Errors and Warnings to use the Error Flat File Trace Listener instead?  Let's see if the same log you posted will get written to the file associated to that trace listener.

<errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Logging Errors Flat File Trace Listener" />
</listeners>

change to

<errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Error Flat File Trace Listener" />
</listeners>

 

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

Apr 14, 2010 at 11:02 AM

Adding to Sarah's response, have you sorted out your SMTP configuration?

From your error stack it is evident that the exception is related to SMTP configuration regard less of your Logging or Exception Handling blocks. Let me try to explain the configuration step by step...

Here is how the blocks are used together to catch an exception and log that , so that you can either write to a flat file or email the error stack or insert into database or custom your logging approch.

Handling exceptions

catch (Exception ex)
            {
                                
                ExceptionPolicy.HandleException(ex, "MyExceptionPolicy");
            }
Configure logging application block to log the exception to flat file and to Email the error stack
You are aware you use Ent Lib configuration tool to configure SMTP and log destination.
You end up having a Web.config quite similar to the one below. (Note that below configuration works perfectly where the exception is logged to flat file as well as an email to send with error stack)
<configSections>
		<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
		<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
		<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
		<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
				<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
				<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
					<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
					<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
					<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
					<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
				</sectionGroup>
			</sectionGroup>
		</sectionGroup>
	</configSections>
	<!-- Enterprise Library Logging and Exception Handling application block configuration starts here -->
	<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
		<listeners>
			<add toAddress="<Email add>" fromAddress="<Email add>" subjectLineStarter="" subjectLineEnder=":Unified Admin Area" smtpServer="<SMTP Server HERE>" smtpPort="25" formatter="Text 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 TraceListener"/>
			<add fileName="C:\Documents and Settings\sgolla\My Documents\Visual Studio 2008\WebSites\MyWebApp\Exceptions_Log" header="----------------------------------------" footer="----------------------------------------" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="FlatFile TraceListener"/>
			<add source="Enterprise Library Logging" formatter="Text Formatter" log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Formatted EventLog TraceListener"/>
		</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=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Text Formatter"/>
		</formatters>
		<categorySources>
			<add switchValue="All" name="General">
				<listeners>
					<add name="Email TraceListener"/>
					<add name="Formatted EventLog TraceListener"/>
					<add name="FlatFile TraceListener"/>
				</listeners>
			</add>
		</categorySources>
		<specialSources>
			<allEvents switchValue="All" name="All Events">
				<listeners>
					<add name="Email TraceListener"/>
					<add name="FlatFile TraceListener"/>
				</listeners>
			</allEvents>
			<notProcessed switchValue="All" name="Unprocessed Category">
				<listeners>
					<add name="Email TraceListener"/>
					<add name="FlatFile TraceListener"/>
				</listeners>
			</notProcessed>
			<errors switchValue="All" name="Logging Errors &amp; Warnings">
				<listeners>
					<add name="Email TraceListener"/>
					<add name="Formatted EventLog TraceListener"/>
					<add name="FlatFile TraceListener"/>
				</listeners>
			</errors>
		</specialSources>
	</loggingConfiguration>
	<exceptionHandling>
		<exceptionPolicies>
			<add name="MyExceptionPolicy">
				<exceptionTypes>
					<add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow" name="Exception">
						<exceptionHandlers>
							<add logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="0" useDefaultLogger="false" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Logging Handler"/>
						</exceptionHandlers>
					</add>
					<add type="System.Security.SecurityException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow" name="SecurityException">
						<exceptionHandlers>
							<add logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="0" useDefaultLogger="false" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Logging Handler"/>
						</exceptionHandlers>
					</add>
					<add type="System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow" name="SqlException">
						<exceptionHandlers>
							<add logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="0" useDefaultLogger="false" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Logging Handler"/>
						</exceptionHandlers>
					</add>
				</exceptionTypes>
			</add>
		</exceptionPolicies>
	</exceptionHandling>
	
Go through the above configuration and let us know further queries.
Jun 11, 2010 at 11:28 AM
Edited Jun 11, 2010 at 11:33 AM

Hi Jayanthi,

From your query, i understand that you are able to log messages and exceptions to flatfile in your local & prod environment
but email trace listener is not able to send email communications in production environment.

Please check with your network administration that whether your smtp server requires authentication or not for sending emails.
If your SMTP server requires authentication then, email trace listener will not work (email trace listener's SMTP settings currently
do not support/accept smtp credentials ) and throws an exception "System.Net.Mail.SmtpFailedRecipientException".

So, to overcome this issue, you need to modify email trace listener code in enterprise library source code that accepts smtp credentials.
I have faced similar situation in my project earlier and i have modified code to accept credentials and it solved my problem.
Let me know if you need the modified source code of enterprise library 4.1.

 

Thanks,
Niranjan