Ent Lib 4.1 - Invalid TraceListenerData type in configuration

Topics: Logging Application Block
Dec 30, 2008 at 2:21 PM
Hi there,

I am trying to set up a logging application block with DataBase trace listener.

I get the error below on the Logger.Write line. I have only a simple web site set up as sample. I have added the references for Common, Data , Logging dlls for the site also added the below.

using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;

Error:
Invalid TraceListenerData type in configuration 'listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"'. (C:\Inetpub\VenuTest\website\web.config line 31)

My Code snippet:

LogEntry logEntry = new LogEntry();
        logEntry.EventId = 100;
        logEntry.Priority = 2;
        logEntry.Message = "Informational message";
        logEntry.Categories.Add("Trace");
        logEntry.Categories.Add("UI Events");
        logEntry.Title = "Test";
        Logger.Write(logEntry);

Web Config file:
<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<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="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>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add databaseInstanceName="LocalSQL" writeLogStoredProcName="usp_LoggingWriteLog"
        addCategoryStoredProcName="usp_LoggingAddCategory" 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}"
        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">
        <listeners>
          <add name="Database Trace Listener" />
        </listeners>
      </allEvents>
      <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="LocalSQL" connectionString="Data Source=MOSSDEV32;Initial Catalog=COS_Release_1_0;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="ServerName" value="mossdev32" />
  </appSettings>
  <system.web>
    <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
    <compilation debug="true">
      <assemblies>
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
      </assemblies>
    </compilation>
    <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
    <authentication mode="Windows" />
    <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </controls>
    </pages>
    <httpHandlers>
      <remove verb="*" path="*.asmx" />
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
    </httpHandlers>
    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="OptionInfer" value="true" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
    </compilers>
  </system.codedom>
  <!--
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="ScriptModule" />
      <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated" />
      <remove name="ScriptHandlerFactory" />
      <remove name="ScriptHandlerFactoryAppServices" />
      <remove name="ScriptResource" />
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>


Dec 31, 2008 at 4:07 AM
Did you add the Logging.Database assembly? If you did, see if the assembly gets copied to the bin folder of your project.

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

Dec 31, 2008 at 12:05 PM
Thanks for the quick response. I did not add the assembly earlier but did it on your suggestion and it eliminated the error. But its not writing the entry to the database.

I think I am missing some step here. I will explain what I did, please correct me.

1. Added a Data Access Application Block with Connection string to the local SQL Server
2. Changed the WriteLog stored procedure name to the my stored procedure
3. In the Logging Application Block added the DataBase trace listener under the Trace Listener
4. Under the Special Source - All Events , I added the DB Trace Listener and referenced it to the above
5. Did the same for Category Sources - General.
6. On button click event wrote this piece of code.

LogEntry logEntry = new LogEntry();
        logEntry.EventId = 100;
        logEntry.Priority = 2;
        logEntry.Message = "Informational message";
        logEntry.Categories.Add("Trace");
        logEntry.Categories.Add("UI Events");
        logEntry.Title = "Test";
        Logger.Write(logEntry);

Thats it. When I debug it runs fine but doesnt log any entry to the table in my local SQL Server.

Please advice.
Thanks




Jan 1, 2009 at 8:33 AM
Just to confirm, do you have the Trace and UI Events categories in your configuration file? Another thing, EntLib comes with a script that installs a database(Logging) for use with the databasetracelistener.  So if you used your own database, you would have to create your own custom database trace listener because you have a different table definition for log entries with that of the Logging db.

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 5, 2009 at 4:45 AM
Please run LoggingDatabase.sql to create the DB Objects.
Jan 8, 2009 at 4:20 PM
Hi Guys,

Thanks for guiding me on this. I missed the sql script and also I did not give acces to the DB for the user - NTAuthority/ Network Service, which runs the web apps.Now I am able to log to the database.

Venu
Consultant
CIBER UK.
Aug 18, 2009 at 3:48 PM

I am getting the same behavior and because there is no clue to what the error could be (it seems ELib is masking the db errors), there is a problem trying to fix the issue.

I am using an Oracle database and have executed the scripts to create the tables and Stored Procedures.

The stored procs are WRITELOG, ADDCATEGORY, and INSERTCATEGORY

How do I know what errors are preventing the database insert?

 

Aug 19, 2009 at 2:06 AM

Yes, entlib handle the exceptions that occurs when the tracelisteners fail.  But what you could do is add a tracelistener under the Logging Errors and Warnings node so if you fail to get the log you are expecting, the tracelistener under that node will log a message indicating that the logging failed and what was the exception that occured. 

 

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

Oct 8, 2009 at 10:32 PM

I'm pissed because I just typed up tons of explanation of my issue with code examples and all and accidently hit the <backspace> key while holding a button on the mouse to lose everything...

I am having the same problem that skvenu ran into.  However, I do not want to run the LoggingDatabase.sql script as I am using a table in a separate database.  This database has a very simple table (5 columns) with a simple stored procedure to populate those columns.  I have setup my configuration in the same order as skvenu and have made sure that I am using and referencing the assemblies necessary for EntLib 4.1. 

The way I am populating the separate table is by having a class that inherits from the base LogEntry class:

        class CheckHoldLogEntry : LogEntry
        {
            private long AccountNumber { get; set; }

            private int Suffix { get; set; }

            private double Amount { get; set; }

            private bool Success { get; set; }

            private string CheckHoldMessage { get; set; }

            // TODO: DETERMINE IF I NEED TO PULL IN THE PARAMETERS FOR BASE
            public CheckHoldLogEntry(long accountNumber, int suffix, double amount, bool success, string checkHoldMessage)
                : base()
            {
                AccountNumber = accountNumber;
                Suffix = suffix;
                Amount = amount;
                Success = success;
                CheckHoldMessage = checkHoldMessage;
            }
        }

I am able to step through all of the code, but after I hit Logger.Write(log), I get the error "InnerException    {"Invalid TraceListenerData type in configuration 'listenerDataType=\"Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\"

        public void PutCheckHold(long accountNumber, long suffix, string amount)
{
var settings = Properties.Settings.Default;
using (var conn = new CacheConnection(ConnectionString))
{
conn.Open();

Database db = null;
db = DatabaseFactory.CreateDatabase("AppDatabase");

string pErrMsg = null;
var cacheStatus = FsgApi.CheckHold(conn, settings.pTellerId, settings.pTellerId, settings.pTellerPwd, accountNumber,
suffix, settings.pHcd, settings.pHrsn, amount, ref pErrMsg);
if (!cacheStatus.IsOK)
{
var errorString = "CHECK HOLD FAILED: " + cacheStatus.Code + " " + pErrMsg;
var log = new CheckHoldLogEntry(accountNumber, (int)suffix, Convert.ToDouble(amount), false, errorString);
Logger.Write(log);
throw new Exception(errorString);
}
else { var log = new CheckHoldLogEntry(accountNumber, (int)suffix, Convert.ToDouble(amount), true, "Successful Check Hold Placement");
Logger.Write(log);

}
}
}

Obviously, this code has a lot of stuff that's not understandable - however, the logging specific code is bolded. 

I am running a unit test to execute this code.

        [Test]
        public void PutCheckHoldTest()
        {
            var provider = new CheckHoldProvider();
            const int acn = 111111111;
            const int suffix = 99;
            const double amount = 5.00;
            provider.PutCheckHold(acn, suffix, amount.ToString());
        }

Here is my stored procedure:

ALTER PROCEDURE [dbo].[LogCheckHold]
(
	@Acn varchar(50),
	@Suffix int, 
	@Amount decimal(19, 2), 
	@Success bit,
	@Message varchar(500)
)
AS
INSERT INTO [LogCheckHold] (
	Acn,
	Suffix, 
	Amount, 
	Success, 
	TimeStamp, 
	Message
)
VALUES (
	@Acn,
	@Suffix, 
	@Amount, 
	@Success, 
	getDate(), 
	@Message)

Finally, here is my configuration:

<?xml version="1.0" encoding="utf-8"?>
<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="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add databaseInstanceName="AppDatabase" writeLogStoredProcName="LogCheckHold"
        addCategoryStoredProcName="AddCategory" 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="Check Hold Events" />
    </listeners>
    <formatters>
    </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="Check Hold Events" />
        </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="Check Hold Events" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <connectionStrings>
    <add name="AppDatabase" connectionString="Data Source=TEST\sql2005;Initial Catalog=AppDatabase;Persist Security Info=True;User ID=sa;Password=TEST"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>
Any help is greatly appreciated!!!

Oct 9, 2009 at 2:54 AM

Did you add the Logging.Database assembly?  Make sure you added it in the executable project.

 

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

Oct 9, 2009 at 1:52 PM

Thanks for the response.  I did add Logging.Database (which was not yet added) but I still get the same exception.

 

Oct 9, 2009 at 3:29 PM
Edited Oct 9, 2009 at 3:30 PM

Here is the BIG QUESTION:

Am I supposed to be using a Database Trace Listener or a Custom Trace Listener?


When I moved the configuration and references into the actual project, not the test, I received the following error when I try to open my app in the browser:

 

An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

 

Which points to:

 

Line 8:      <loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">

 

Here is how the configSections are setup currently for my 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" />
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>

 

I am referencing all of the following even though some are obviously not necessary for my specific configuration.  .Caching, .Common, .Data, .Data.SqlCe, .ExceptionHandling, .ExceptionHandling.Logging, .Logging, .Logging.Database.

There is more being done with this config, but logging custom values to the database is my only issue.

Thank you!

 

Oct 12, 2009 at 7:30 AM

Yes. Ideally you would implement a custom database trace listener and provide your own logic of inserting the logs to the database. See this : http://customdatabasetracelistener.blogspot.com/2009/06/custom-dbtracelistener-w-custom.html

Valiant Dudan
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Nov 16, 2009 at 9:15 PM

I was getting following error:

{"Invalid TraceListenerData type in configuration 'listenerDataType=\"Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData,

Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\"'.

 (C:\\My\\Projects\\SimpleExceptionSample01\\SimpleExceptionSample01\\bin\\Debug\\SimpleExceptionSample01.vshost.exe.Config line 12)"}

 Solution:

Look minutely following namespace is missing Microsoft.Practices.EnterpriseLibrary.Logging.Database means this assembly in references is missing.

It it assumed that database exist in instance of SQL Server.

I have added reference to the assembly and it has started logging.

Make sure following assemblies are present in references:

1. Microsoft.Practices.EnterpriseLibrary.Common

2. Microsoft.Practices.EnterpriseLibrary.ExceptionHandling

3. Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging (this is missing assembly reference)

4. Microsoft.Practices.EnterpriseLibrary.Logging.Database

5. Microsoft.Practices.ObjectBuilder2

Uday Shastri

MicroArchitect.com