locked
Ent-Lib 2.0- Problem Configuring Database Listener for Logging Block RRS feed

  • Question

  • User313706618 posted

    Hello,

    I have been trying to configure a databse listener, pointing to a local SQL Express Database, but I keep getting the following error.

    Invalid TraceListenerData type in configuration 'listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null

    I tried using  the default Logging database (created by the the create DB command  from the Ent-Lib start menu), and also with the Logging tables and stored procs created in another Database.

    I have a flat file trace listener that works fine, when I remove the Db trace listener, but doesn't work with it.

    Thanks!

    Here is my web.config snippet:

    <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
        defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
        <listeners>
          <add databaseInstanceName="LogDBConn" writeLogStoredProcName="WriteLog"
            addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
            listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
            traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
            name="Database Trace Listener" />
          <add fileName="C:\ProjectsDEV\FAB_RefApp\TraceOutput\RefApp_Trace.log"
            header="!----------------------------------------!" footer="X----------------------------------------X"
            formatter="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
            traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
            name="FlatFile-TL" />
        </listeners>
        <formatters>
          <add template="Timestamp: {timestamp}{newline}Message: {message}{newline}Category: {category}{newline}Priority: {priority}{newline}EventId: {eventid}{newline}Severity: {severity}{newline}Title:{title}{newline}Machine: {machine}{newline}Application Domain: {appDomain}{newline}Process Name: {processName}{newline}Thread Name: {threadName}{newline}Extended Properties: {dictionary({key} - {value}
    )}"
            type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
            name="Text Formatter" />
        </formatters>
        <categorySources>
          <add switchValue="All" name="DBLog">
            <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 & Warnings">
            <listeners>
              <add name="FlatFile-TL" />
            </listeners>
          </errors>
        </specialSources>
      </loggingConfiguration>
     
    Monday, May 22, 2006 1:41 AM

All replies

  • User-406147651 posted

    Hello.

    Your project It will OK, if 'Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll' is referred to.

    Wednesday, May 31, 2006 10:02 PM
  • User-1296151564 posted

    Hello.

    Your project It will OK, if 'Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll' is referred to.



    My problem was identical with this. Adding a reference to the Logging.DataBase.dll does indeed resolve the problem.
    Well done Takashi.
    Monday, June 19, 2006 9:55 AM
  • User1193552644 posted

    Hello.

    Your project It will OK, if 'Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll' is referred to.

    Good Answer...I faced the same problem and its resolved by your reply :)

    Thursday, July 20, 2006 4:11 PM
  • User1993891967 posted

    thank you takishi.

     

     

    Wednesday, February 21, 2007 12:55 PM
  • User1993891967 posted
    and takashi. thank you to you both. [:)]
    Wednesday, February 21, 2007 12:56 PM
  • User-608679614 posted

    Hi i am also facing the same problem, but i ma using Enterprise Library 2.0 and i cant find Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll to add as the reference, please help, thanks.

    Sunday, April 1, 2007 7:08 AM
  • User-1037305256 posted

    Good answer

    Monday, August 6, 2007 2:39 AM
  • User-491781209 posted

     Hey I am also trying to write logs to datatabase.....

     <listeners>
          <add databaseInstanceName="Connection String" writeLogStoredProcName="WriteLog"
            addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
            listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
            traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
            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=2.9.9.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
            name="Text Formatter" />
        </formatters>

     databaseInstanceName="Connection String"..i have given my connection string..

     writeLogStoredProcName="WriteLog"...stroed procedure name from my database

      addCategoryStoredProcName="AddCategory"...what is this for?? its  given default value...

     

    If we are trying to write our log to stroed procedure where to name it and how to pass values to it in .cs file...please help..

    I have a stored procedure written which takes 4 input paramaters how do i pass values to them from logger.write method.. 

    Tuesday, August 28, 2007 11:56 AM
  • User-647239214 posted

    Im also encountering the same problem Invalid TraceListenerData type.

    I have added the reference to Logging.Database but to no avail.. same problem.

    I'm using netTiers as my DAL. does not Logging Application Block work with other DAL?

    Monday, November 19, 2007 3:04 AM
  • User-647239214 posted

    I was able to partyly figure out some issues I have encountered.  These are some things we need to be cautious of when using EntLib.

    1) Make sure to use the correct DLLs.  When you install EntLib, there is 2 versions.  One in EntLib3Src\AppBlocks\Src and the other one in Program Files\Microsoft Enterprise Library 3.1 - May 2007\..... The basic difference is that one is signed and other is unsigned.  Take note that each version has its own Enterprise Library Configuration which generates the necessary sections in your web.config.

    The generated sections in the web.config need to match with the DLL you are using so make sure to use the right Ent Lib Configuration.

    Error that you'll get when using the incorrect versions is something like "manifest do not match...." sorry can't remember the whole line.

    2) When using Database Trace Listener, make sure to set the type of Formatter.  This is really plain silly as EntLib is not giving me specific error on this.  I played around the whole day before figuring out the problem that I did not set the Textformatter.

    However, as of this writing, I'm still having problems with the database trace listener.  I have succesfully bypassed all errors but nothing is being logged in my database....???

    any thoughts?

    Tuesday, November 20, 2007 9:00 PM
  • User-647239214 posted

    was able to figure out the problem.

    I have changed the table names but fail to change the table names in the SPs. wahhhh

    hope EntLib could have given me a more meaningful error message regarding this.

    Tuesday, November 20, 2007 9:59 PM
  • User-846044174 posted

    Has anyone ever changed the database for database logging at runtime? We have several environments that we move code though dev, QA and finally production. Each environment has its own database for logging. What I wanted to do is use our custom object that returns environment then set approriate db for logger at runtime.

    Wednesday, January 14, 2009 12:30 PM