The configuration section for Logging cannot be found in the configuration source

Topics: Exception Handling Application Block, Logging Application Block
Jun 30, 2011 at 7:10 AM

I have a class library of silverlight which contains my edmx and enterprise library dlls and I have my code for logging in one of the classes of this class library project. In the App.Config of this project I have specified the appropriate sections under <configSections>. Also I have specified the required tags for <loggingConfiguration> and <exceptionHandling> under <configuration>.

   <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" />
  </configSections>

The reference of this sliverlight class library project is being used in a web project. the issue is when my log function is called, it gives following error at Writelog function.

"The configuration section for Logging cannot be found in the configuration source."

Can someone provide a solution?

Jun 30, 2011 at 8:26 AM

Hi,

The normal Enterprise Library assemblies will not work with Silverlight since it uses the custom version of CLR and .NET framework. You need to use the Silverlight Integration Pack for Enterprise Library 5.0. With the Integration Pack, the config should be defined on XAML (configuration.xaml) file instead of the traditional .config file.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jul 1, 2011 at 7:41 AM

Hi

I just realized that though I am using sliverlight in my solution but the class library which contains the enterprise library's dll and my logging code is NOT a silverlight class library, it's a simple C# class library; hence Silverlight Integration Pack for Enterprise Library 5.0 is not needed.

Apologize for earlier mentioning it as Silvlerlight Class Library.

Kindly provide your comments at the earliest.

Jul 1, 2011 at 8:24 AM

Do you have the configuration file inside your class library? Note that the config should be defined on the application that references the class library and not on the class library itself.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jul 1, 2011 at 11:33 AM

Hi Noel

Your comment is useful, I was in the impression that the class library's config file should be used.

I am going to try it now.

Jul 4, 2011 at 10:34 AM

Hi

After making the aforesaid changes, I am facing the following issue.

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter, null]) failed: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, Inventory_DevEntities]) failed: Unable to find the requested .Net Framework Data Provider.  It may not be installed. (Strategy type ConfiguredObjectStrategy, index 2) (Strategy type ConfiguredObjectStrategy, index 2)

Please reply ASAP.

Jul 4, 2011 at 10:38 AM

Are you using the logging with database feature? If yes, what database are you using? Did you already add the Data Access Block to your config?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Jul 4, 2011 at 11:40 AM

Yes, I am doing logging with database feature. I am using a SQL Server 2008 DB. And I have already added a Data Access Block. Please see below the details:

  <configSections>

    <sectionGroup name="system.serviceModel">
      <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" />
    </sectionGroup>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

  </configSections>

 

<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add databaseInstanceName="Inventory_DevEntities" writeLogStoredProcName="WriteLog" addCategoryStoredProcName="AddCategory" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Database 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="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="Database 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="Database Trace Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>

 

<connectionStrings>

    <add name="Inventory_DevEntities" connectionString="metadata=res://*/Inventory.csdl|res://*/Inventory.ssdl|res://*/Inventory.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=Safaltek143;Initial Catalog=Inventory_Dev;Persist Security Info=True;User ID=sa;Password=Password;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

  </connectionStrings>

Jul 5, 2011 at 3:58 AM

How did you construct your configuration? Did you use the Configuration Editor? You are getting the exception because you are connecting to Sql Server yet you are using System.Data.EntityClient as your provider. It should be System.Data.SqlClient.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com