Integrating WCF into the Logging Application Block...

Topics: Logging Application Block
Aug 17, 2007 at 6:23 AM
Hi,

i've been tinkering around trying to figure out if there is a way for WCF to be integrated into the Logging Application Block and while at it... i came upon this article:.
http://weblogs.asp.net/cibrax/archive/2007/06/18/integrating-the-wcf-trace-with-the-logging-application-block.aspx
but when i tried to implement the codes... they don't seem to work. per sample, the logs is in xml format...

has anyone tried to integrate WCF into the Logging Application Block here?... can somebody, anybody provide me links pertaining to this?
niways, thanks in advance....
Aug 17, 2007 at 1:55 PM
Hi,

What kind of integration are you looking for? The integration provided by EntLib, and described by Pablo in his post, will route entries logged by WCF to the standard System.Diagnostics trace features to the logging block. These entries are XML by design, as WCF XML logs itself.

Fernando
Aug 21, 2007 at 4:43 AM
i was just trying to have the WCF integrated into the logging application block... however, i got the apps running, (app consumer & the service) but i could not find the xml files...
my intention was merely to replicate what was discussed in the code....

and since i could not get it to work... i am inquiring if anyone was able to make it work...

moving forward, i am looking to create an logging architecture for our SOA based project... i was able to use the tracelogging generated from wcf... but i noticed that it seems to be a very large file...
would it be a good idea to try to use the tracelog or integrate them into the logging application block?


Aug 21, 2007 at 1:07 PM
If you can post the config section i can have a look at it..

mean while also have a look where you are adding EntLibLoggingProxyTraceListener as a listener under system.diagnostics

<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Information,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EntLibLoggingProxyTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging" name="traceListner">
<filter type="" />
</add>
</listeners>
</source>
</sources>
</system.diagnostics>

As your second question is concerned an ideal solution would be to use MSMQ Trace listener for logging messages and then use MsmqDistributer to log it to the database offline.
Aug 21, 2007 at 2:06 PM
Hi,


moving forward, i am looking to create an logging architecture for our SOA based project... i was able to use the tracelogging generated from wcf... but i noticed that it seems to be a very large file...
would it be a good idea to try to use the tracelog or integrate them into the logging application block?


You're supposed to use the Microsoft Service Trace Viewer to navigate the log file (http://msdn2.microsoft.com/en-us/library/ms732023.aspx).

Regards,
Fernando
Apr 26, 2012 at 9:57 AM
Edited Apr 26, 2012 at 10:01 AM

Hi all,

I've succeeded in redirecting System.ServiceModel.MessageLogging traces to the Enterprise Library Logging Application Block, but only combined with a FlatFileTraceListener.

But my actual intent is to use an MsmqTraceListener for routing the traces to a DistributorService that finally logs them.

The problem is that the combination of the MsmqTraceListener and System.ServiceModel.MessageLogging doesn't work for me. The messages do not appear in the queue.

However, my application's exception messages, which use the Enterprise Library's LoggingExceptionHandler and then the same MsmqTraceListener, do appear.

So it is something that makes text formatted exception messages different to WCF message trace messages what causes the problem. But I can't figure it out.

Have anyone succeeded in a similar scenario (<messageLogging> plus System.Diagnostics' EntLibLoggingProxyTraceListener plus Enterprise Library's MsmqTraceListener)?

Thank you very much.

This is an excerpt from my Web.config:

  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>


  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="System.ServiceModel.MessageLogging">
    <listeners>
      <add name="BinaryMessageQueuingTraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.MsmqTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.MsmqTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        queuePath=".\Private$\LoggingQueue" formatter="BinaryLogMessageFormatter"
        recoverable="true" transactionType="Single" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.BinaryLogFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="BinaryLogMessageFormatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="BinaryMessageQueuingTraceListener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings" />
    </specialSources>
  </loggingConfiguration>

  <system.serviceModel>
    <diagnostics>
      <messageLogging
           logEntireMessage="true"
           logMalformedMessages="false"
           logMessagesAtServiceLevel="true"
           logMessagesAtTransportLevel="false"/>
    </diagnostics>
  </system.serviceModel>


  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging" switchValue="Information, ActivityTracing">
        <listeners>
          <add name="TraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EntLibLoggingProxyTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

Apr 27, 2012 at 3:52 AM

Try setting the errors specialSource to write to a FlatFileTraceListener and see if any errors are occurring while processing the LogEntry.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com