A big problem with configuration

Topics: Logging Application Block
Oct 3, 2007 at 1:07 PM
Hello Guys,
Have a big problem with using Enterprise Library 2006 Error Handling and Logging component. Let me explain step by step what the problem is. Here is my loggingConfiguration section:
<loggingConfiguration name="Logging Application Block" tracingEnabled="false" defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<clear/>
<add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="None" type="Myowncompany.Logging.CustomDbErrorLogger, Myowncompany" name="Custom DatabaseTrace Listener" initializeData="" formatter="Text Formatter_Database"/>
<add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="None" type="Myowncompany.Logging.CustomDbLogger, Myowncompany" name="Custom SQL AuditTrace Listener" initializeData="" formatter="Text Formatter_Database"/>
<add toAddress="someemail@somedomain.com" fromAddress="someemail@somedomain.com" subjectLineStarter="" subjectLineEnder="owncompany logging Error" smtpServer="localhost" smtpPort="25" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Email TraceListener"/>
<add source="OwnCompany" formatter="" log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Formatted EventLog TraceListener"/>
<add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.SystemDiagnosticsTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="System.Diagnostics TraceListener" initializeData=""/>
</listeners>
<formatters>
<clear/>
<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=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Text Formatter"/>
<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;)}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Text Formatter_Database"/>
</formatters>
<categorySources>
<add switchValue="All" name="Audit">
<listeners>
<add name="Custom SQL AuditTrace Listener"/>
</listeners>
</add>
<add switchValue="All" name="LoggingError">
<listeners>
<clear/>
<add name="Formatted EventLog TraceListener"/>
<add name="Email TraceListener"/>
</listeners>
</add>
<add switchValue="All" name="Error">
<listeners>
<clear/>
<add name="Custom DatabaseTrace Listener"/>
<add name="Formatted EventLog TraceListener"/>
<add name="Email TraceListener"/>
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events"/>
<notProcessed switchValue="All" name="Unprocessed Category"/>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<clear/>
<add name="System.Diagnostics TraceListener"/>
</listeners>
</errors>
</specialSources>
</loggingConfiguration>

Also Home Directory for default web site in IIS is "c:\mysite" also there are several virtual directory under default web site all point to the same folder "c:\mysite".

Everything works fine until calling Logger.Write(somelogEntry); in the code of application. if its called the following error is appear:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The entry 'Custom DatabaseTrace Listener' has already been added.

Source Error:


<listeners>
<clear/>
<add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="None" type="Myowncompany.Logging.CustomDbErrorLogger, Myowncompany" name="Custom DatabaseTrace Listener" initializeData="" formatter="Text Formatter_Database"/>
<add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="None" type="Myowncompany.Logging.CustomDbLogger, Myowncompany" name="Custom SQL AuditTrace Listener" initializeData="" formatter="Text Formatter_Database"/>
<add toAddress="someemail@somedomain.com" fromAddress="someemail@somedomain.com" subjectLineStarter="" subjectLineEnder="owncompany logging Error" smtpServer="localhost" smtpPort="25" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Email TraceListener"/>


Can anybody help me with this? Thanks a lot!
Oct 4, 2007 at 12:40 AM
It looks like ASP.NET may be automatically merging several web.config files (and possibly machine.config) which is resulting in a duplicate entry in your logging configuration.

Tom
Oct 4, 2007 at 7:32 AM
Hi Tom, yes it is. The solution was to chage default folder for web site to other folder.
Oct 4, 2007 at 8:51 AM
I also found solution with <location inheritInChildApplications="false"> details http://forums.iis.net/p/994377/1297968.aspx#1297968