Configuration error when using 4.1: An error occurred creating the configuration section handler for loggingConfiguration

Topics: Logging Application Block
Aug 26, 2011 at 10:19 PM

We have a web application that's using Enterprise Library for a couple of things. When one of our developers added the Logging Application Block for the first time (atleast we thought it was the first time), we got an error like this:

Parser Error Message: An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

We've added version 4.1 of the Common, Exception Handling and Logging blocks. The web.config looks like this:

Line 112:  <loggingConfiguration configSource="Instrumentation.config" />

The file it refers to looks like this:

	<loggingConfiguration tracingEnabled="true" defaultCategory="Error">
     
    <!-- Under category sources, you associate each source (message type) with a listener (message destination).
         NOTE: Each source can have zero or more listeners.
    -->
		<categorySources>
			<add name="Error" switchValue="All">
				<listeners>
					<add name="Event Log" />
				</listeners>
			</add>  

			<add name="Warning" switchValue="All">
				<listeners>
				  <add name="Event Log" />
				</listeners>
			</add>

			<add name="Information" switchValue="All">
				<listeners>
					<add name="Event Log" />
				</listeners>
			</add>

			<add name="Verbose" switchValue="All">
				<listeners>
					<add name="Event Log" />
				</listeners>
			</add>

			<add name="UrlAliasing" switchValue="All">
				<listeners>
					<add name="Event Log" />
				</listeners>
			</add>

			<add name="CommerceOrder" switchValue="All">
				<listeners>
					<add name="Commerce Audit Log" />
				</listeners>
			</add>
			
			<add name="CommerceAuthentication" switchValue="All">
				<listeners>
					<add name="Commerce Audit Log" />
				</listeners>
			</add>

			<add name="CommerceRightsAccess" switchValue="All">
				<listeners>
					<add name="Commerce Audit Log" />
				</listeners>
			</add>

      <add name="Tracing" switchValue="All">
        <listeners>
          <add name="Trace" />
        </listeners>
      </add>
			
		</categorySources>

      <!-- General errors may occur during log writing.  This setting determines where those errors get logged.-->
		<specialSources>
			<errors name="errors" switchValue="All">
				<listeners>
					<add name="Event Log" />
				</listeners>
			</errors>
		</specialSources>

    <!--
    The Listeners node is where you define and configure any possible listeners.  The Application Block comes with many default 
    listeners and you can also write your own. Please see Microsoft's Logging Application Block documentation for more information.
    http://msdn.microsoft.com/en-us/library/cc309506.aspx
    -->
		<listeners>
			<add name="Event Log" 
				type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging" 
				listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging" 
				source ="CMS400" 
				formatter="Text Formatter"
				machineName="."
			/>
      <add name="Commerce Event Log"
				type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"
				listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
				source ="CMS400 Commerce"
				formatter="Text Formatter"
				machineName="."
			/>
			<add name="Flat File" 
				type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging" 
				listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging" 
				fileName ="trace.log" 
				header="----------------header------------------------" 
				footer="----------------footer------------------------" 
				formatter="Text Formatter"
			/>
      <add name="Rolling File"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration, Microsoft.Practices.EnterpriseLibrary.Logging"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
        fileName="logs\trace.log"
        rollFileExistsBehavior="Overwrite" 
        rollInterval="Day"
				formatter="Rolling Text Formatter" 
			/>

      <add name="Trace"
       type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration, Microsoft.Practices.EnterpriseLibrary.Logging"
       listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
       fileName="logs\tracing.log"
       rollFileExistsBehavior="Overwrite"
       rollInterval="Day"
       formatter="Trace Formatter"
			/>
      <add name="Commerce Audit Log"
       type="Ektron.Cms.Instrumentation.TraceListeners.DatabaseTraceListener, Ektron.Cms.Instrumentation"
       listenerDataType="Ektron.Cms.Instrumentation.TraceListeners.DatabaseTraceListenerData, Ektron.Cms.Instrumentation"
       formatter="DB Formatter"
			/>
		</listeners>

    <!--
    You'll notice that many of the listerners are also associated with a text formatter.  
	These text formatters determine what the message actually looks like when written out. 
    -->
		<formatters>
			<add template="{timestamp} PID-{processId} TID-{win32ThreadId} Level-{severity} Message-{message}"
				type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
				name="Rolling Text Formatter" 
			/>

			<add
				name="Text Formatter"
				type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
				template="Timestamp: {timestamp}
Message: {message}
Category: {category}
Priority: {priority}
EventId: {eventid}
Severity: {severity}
Title:{title}
Machine: {machine}
Application Domain: {appDomain}
Process Id: {processId}
Process Name: {processName}
Win32 Thread Id: {win32ThreadId}
Thread Name: {threadName}
Extended Properties: {dictionary({key} - {value}
)}"
				/>

      <add
        name="Trace Formatter"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
        template="Timestamp: {timestamp} - Message: {message})}"/>

    <add
       name="DB Formatter"
       type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
       template="{message}"/>
    
    </formatters>
	</loggingConfiguration>

Aug 30, 2011 at 5:56 AM
Edited Aug 30, 2011 at 5:58 AM

Hi,

Is this an existing application or a new one? Try to put the fully qualified name of Enterprise Library and see if this works? You can use the config editor to help you do that. Basically, it automatically generates the fully qualified name for you.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us