DataBase Logging TraceListener Config Error

Topics: Logging Application Block
Jun 6, 2012 at 5:48 PM
Edited Jun 6, 2012 at 5:52 PM

Hi,

Here is what I have done assuming we have the dlls and references in my projects and we have logging working with an eventviewer but now we have a need for a DB logger,

  1. Downloaded EntLib50Src, Ran the script CreateLoggingDB in "EntLib50Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts"
  2. Verified the database was created on a local SQL Server Express with the name "Logging"
  3. In "EntLib50Src\bin" ran the tool EntLibConfig.exe and generated a database log listener config file. For the sake of space and relevancy I removed the event viewer log config. So my question is where is the mistake in the configuration, I recieve this exception:
Invalid TraceListenerData type in configuration 'listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"'.
<configuration>
    <configSections>
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
        <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=null" requirePermission="true" />
    </configSections>
    <dataConfiguration defaultDatabase="ConnectionString" />
    <connectionStrings>
       <add name="ConnectionString" connectionString="Database=Logging;Server=(local)\SQLEXPRESS;Integrated Security=SSPI;Connection Timeout=60"/>
  </connectionStrings>    
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
        <listeners>
      <add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      databaseInstanceName="ConnectionString" writeLogStoredProcName="WriteLog"
      addCategoryStoredProcName="AddCategory" formatter="Text Formatter"  />
        </listeners>
        <formatters>
            <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, PublicKeyToken=31BF3856AD364E35, Culture=neutral" template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}" 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>
</configuration>
Jun 6, 2012 at 6:16 PM
Edited Jun 6, 2012 at 6:27 PM
  

Attempt to solve:

  1. Add References to Enterprise Library Logging.Database to the "Test" Class or Driver Resulting Exeception:

Activation error occured while trying to get instance of type LogWriter, key ""

 

 Resolved

<add name="ConnectionString" connectionString="Database=Logging;Server=(local)\SQLEXPRESS;Integrated Security=SSPI;Connection Timeout=60"  providerName="System.Data.SqlClient"/>

 

Make Sure you add providerName.

PS: how do you remove the code snippet..?

Jun 7, 2012 at 12:53 AM

> PS: how do you remove the code snippet..?

 Do you mean the empty code snippet at the beginning of your previous post?  If so, then I've found that sometimes you need to use the HTML edit button and edit the HTML by hand.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com