Log all my Trace.Write statements to database via EntLib

Topics: Logging Application Block
Jan 6, 2009 at 5:38 PM
I have a WCF service library which has Trace.WriteLine() and Trace.WriteLine() statements throughout.

I log the output of these statements to xml like this:

  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Off">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="System.Runtime.Serialization" switchValue="Off">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="All">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="Hgvc.Business.Club" switchValue="All">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="Hgvc.Business.Common" switchValue="All">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="Hgvc.Business.Reservation" switchValue="All">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="Hgvc.Business.Marketing" switchValue="All">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\logs\Traces13.svclog" />
    </sharedListeners>
    <trace autoflush="false" indentsize="4">
      <listeners>
        <add name="xml" />
      </listeners>
    </trace>
  </system.diagnostics>

My question is, can I log this to a database using the enterprise library?

I followed the instructions at: Integrating the Logging Application Block with WCF Applications, but it only describes how to log to xml, which as I said, I already have. 

The article says I can " use any of the trace listeners supported by the Logging Application Block with WCF", however when I attempt to follow the instructions to configure the WCF-integration trace listeners, and substitute Database Trace Listener in place of XML Trace Listener, I still get no results in my logging database.


Jan 7, 2009 at 1:15 AM
Make sure you have run the LoggingDatabase.sql script to create the Logging database and you've set the WriteLogStoredProcedureName property to WriteLog. 

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