title: EntLib 6 Logging Block on SQL issue with TraceListenerData
body: <p>I want to log my application with Enterprise Library 6 in a SQL DB.</p>
  
  <p>I launched the SQL scripts to create SQL things, and I decided to put Logger in Class Library.</p>
  
  <p>Here is the code i've done in order to make the POC:</p>
  
  <p>Portable Class content:</p>
  
  <pre><code>public static void LogToDatabase()
  {
      try
      {
          //Bootstrapping logging
          DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
          IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
          LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
          Logger.SetLogWriter(logWriterFactory.Create());
  
          if (Logger.IsLoggingEnabled())
          {
  
              LogEntry log = GetLogEntry();
              log.Categories.Add("General");  // name of Categorie in EntLib Config editor
              log.Priority = 5;
              log.Severity = System.Diagnostics.TraceEventType.Information;
              log.Message = "Hello dude, from Logger";
              Logger.Write(log);
  
          }
  
      }
      catch (Exception ex)
      {
      }
  }
  
  private static LogEntry GetLogEntry()
  {
      LogEntry log = new LogEntry();
      log.TimeStamp = DateTime.Now;
      log.Title = "TANOLIS";
      log.Priority = 5;                       // default priority
      log.Severity = System.Diagnostics.TraceEventType.Verbose;  // default severity
      log.MachineName = "MachineName";//HttpContext.Current.Server.MachineName;
      log.ProcessId = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
      return log;
  }
  </code></pre>
  
  <p>And this is the Config string I've done in the Unit test (where I launch the LogToDatabase()) :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" /&gt;
      &lt;section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" /&gt;
    &lt;/configSections&gt;
    &lt;loggingConfiguration name="" tracingEnabled="true" defaultCategory="General"&gt;
      &lt;listeners&gt;
        &lt;add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          databaseInstanceName="DB_Belval" writeLogStoredProcName="WriteLog"
          addCategoryStoredProcName="AddCategory" formatter="DB Command Formatter" /&gt;
      &lt;/listeners&gt;
      &lt;formatters&gt;
        &lt;add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          template="Timestamp: {timestamp}{newline}&amp;#xA;Message: {message}{newline}&amp;#xA;Category: {category}{newline}&amp;#xA;Priority: {priority}{newline}&amp;#xA;EventId: {eventid}{newline}&amp;#xA;Severity: {severity}{newline}&amp;#xA;Title:{title}{newline}&amp;#xA;Machine: {localMachine}{newline}&amp;#xA;App Domain: {localAppDomain}{newline}&amp;#xA;ProcessId: {localProcessId}{newline}&amp;#xA;Process Name: {localProcessName}{newline}&amp;#xA;Thread Name: {threadName}{newline}&amp;#xA;Win32 ThreadId:{win32ThreadId}{newline}&amp;#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
          name="DB Command Formatter" /&gt;
      &lt;/formatters&gt;
      &lt;categorySources&gt;
        &lt;add switchValue="All" name="General"&gt;
          &lt;listeners&gt;
            &lt;add name="Database Trace Listener" /&gt;
          &lt;/listeners&gt;
        &lt;/add&gt;
      &lt;/categorySources&gt;
      &lt;specialSources&gt;
        &lt;allEvents switchValue="All" name="All Events" /&gt;
        &lt;notProcessed switchValue="All" name="Unprocessed Category" /&gt;
        &lt;errors switchValue="All" name="Logging Errors &amp;amp; Warnings"&gt;
          &lt;listeners&gt;
            &lt;add name="Database Trace Listener" /&gt;
          &lt;/listeners&gt;
        &lt;/errors&gt;
      &lt;/specialSources&gt;
    &lt;/loggingConfiguration&gt;
    &lt;dataConfiguration defaultDatabase="MY-DB" /&gt;
    &lt;connectionStrings&gt;
      &lt;add name="DB_Belval" connectionString="Data Source=server;Initial Catalog=catalog;Persist Security Info=True;User=username;Password=pwd"
        providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The error comes in this line:</p>
  
  <pre><code>LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
  </code></pre>
  
  <p>and is </p>
  
  <pre><code>Invalid TraceListenerData type in configuration 'listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"'.
  </code></pre>
  
  <p>Thanks to help me :-)</p>