Can't Log from WCF Service

Topics: Logging Application Block
Feb 5, 2009 at 10:33 PM
Edited Feb 5, 2009 at 10:50 PM
I just tried the logging application block with a simple console application and it worked just fine. Now, I am trying to log something from a WCF service but I do not see anything in the logs. I followed the directions on this page: http://msdn.microsoft.com/en-us/library/cc511861.aspx. Please let me know if I am missing something here. Here are the relevant parts of my web.config:



  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"

    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">

    <listeners>

      <add fileName="C:\Users\xxxxx\Desktop\trace.log" header="----------------------------------------"

        footer="----------------------------------------" formatter=""

        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        name="FlatFile TraceListener" />

      <add source="Enterprise Library Logging" formatter="Text Formatter"

        log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        name="Formatted EventLog TraceListener" />

      <add fileName="C:\Users\ashishvi\Desktop\trace-xml.log" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.XmlTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        name="XML 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=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        name="Text Formatter" />

    </formatters>

    <categorySources>

      <add switchValue="All" name="System.ServiceModel">

        <listeners>

          <add name="XML Trace Listener" />

        </listeners>

      </add>

      <add switchValue="All" name="General">

        <listeners>

          <add name="FlatFile TraceListener" />

        </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="Formatted EventLog TraceListener" />

        </listeners>

      </errors>

    </specialSources>

  </loggingConfiguration>

 

  <system.diagnostics>

    <sources>

      <source name="System.ServiceModel" switchValue="Information,ActivityTracing"

        propagateActivity="true">

        <listeners>

          <add type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EntLibLoggingProxyTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"

            name="traceListener" traceOutputOptions="Timestamp, ProcessId">

          </add>

        </listeners>

      </source>

    </sources>

  </system.diagnostics>

 

 

  <system.serviceModel>

    <diagnostics>

      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />

    </diagnostics>

 

Feb 6, 2009 at 1:16 AM
Edited Feb 6, 2009 at 2:11 AM
Did you check the EventViewer? There may be an error log.  Is your WCF service and console application the same?  I mean, did you just convert your console app to a WCF service?  It'll be better to investigate your own solution, would you mind sending it to me?

Follow-up question, does the file get created but no logs added or the file doesn't get created at all? 


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