5

I have a WPF app using Enterprise Library.Logging 5, .NET Framework 4.0 Client Profile

I used of logging by Database logic. Also add reference to 3 dlls to project.

Microsoft.Practices.EnterpriseLibrary.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll

I have 1 runtime error when logEntry.Write(log) by this message :

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

My app.config is:

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="false">
  <listeners>
    <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      source="Enterprise Library Logging" formatter="Text Formatter"
      log="" machineName="." traceOutputOptions="None" />
    <add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      databaseInstanceName="Logging" writeLogStoredProcName="WriteLog"
      addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
      traceOutputOptions="LogicalOperationStack, DateTime, Timestamp" />
  </listeners>
  <formatters>
    <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      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>
  <logFilters>
    <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      name="Category Filter" />
  </logFilters>
  <categorySources>
    <add switchValue="All" name="Repository" />
    <add switchValue="All" autoFlush="false" name="General" />
    <add switchValue="All" name="TraceDB">
      <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="Event Log Listener" />
      </listeners>
    </errors>
  </specialSources>
</loggingConfiguration>

What is my problem?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Ehsan
  • 3,431
  • 8
  • 50
  • 70
  • If you will remove first listener, will you get the same exception regarding second listener? – abatishchev Oct 11 '11 at 14:49
  • See [this blog post](http://techiethings.blogspot.com/2009/04/enterprise-library-error-invalid.html) – abatishchev Oct 11 '11 at 14:49
  • Thank you for your edit. First listener is correct during program execute. But by add second listener, both listener not execute. My config is similar sample logging project in MSDN, but it is correct and this is not correct. The biggest difference between my app and sample is version of Framwork. My app Framwork is 4 client & it is 3.5 . – Ehsan Oct 12 '11 at 09:27
  • Do you mean, that MSDN example's target version is 3.5? Also could you please provider a link to it? – abatishchev Oct 12 '11 at 09:40
  • excuse me Sample in MSDN was wrong. It sample exist in CodePlex [link](http://entlib.codeplex.com/releases/view/46741#DownloadId=140302) – Ehsan Oct 12 '11 at 10:47

4 Answers4

4

The issue is that you are using the Data block (via the Database Trace Listener). This has a dependency on the .NET Framework Data Provider for Oracle which is a Feature Not Included in the .NET Framework Client Profile.

The workaround is to target .NET Framework 4 instead of the Client Profile.

Randy Levy
  • 22,566
  • 4
  • 68
  • 94
  • My problem resolved by change version Framwork from 4 client to 4, But is it anyway except change version Framework? – Ehsan Oct 12 '11 at 13:45
2

For me it was simple error - It disappeared when I added the Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll to my project.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Nachie
  • 21
  • 1
2

Changing the target framework to .NET 4 instead of the client profile fixed the issue. All other forums say to add a reference to Logging.Database which is still probably required but none mention the target framework. Thanks.

1

The above answer's didn't resolve my issue. For me, I created a class lib project just for Enterprise Library logging. I added all appropriate references for the class library project to build, but received the error at runtime when attempting to write to the log database. To fix, I had to add the Ent Lib DLL references to the "calling" application project in Vis Studio, since at runtime it apparently had no clue what the logging configuration was.

ewitkows
  • 3,528
  • 3
  • 40
  • 62
  • I am facing the same problem. But i don't want to add reference in calling applications. as they are over 15 different projects. :( – Mazhar Karimi Jul 25 '13 at 08:48
  • A potential fix is to create some type of logging WCF\Web service, and just call out to that? – ewitkows Jul 25 '13 at 13:09