Using Distributor services and Logging Application Block

Mar 24, 2009 at 10:20 AM

Currently i am working on a project which implements WCFservice and SilverLight with Web application. I am focusing to Log information using Enterprise Library 4.1 Logging application Block.

Also, I want to log all the information (including WCFservice, Web application) into a centralized located single log file. For this to achieve Iused the concept of Distributed services as mentioned in the below link-

http://msdn.microsoft.com/en-us/library/cc309264.aspx

 

This link says to distribute log entries to a central destination, configure the application to write log entries to the Message Queuing trace listener. When the application sends a log entry to the Logging Application Block, it places the log entry on a Message Queuing queue. The distributor service runs as a Windows service on either the same computer as the application or on a remote computer. If there are log entries on the queue, the distributor service uses an instance of the Logging Application Block to forward the messages to the trace listener(s). The trace listener(s) write the log entries to the destinations, such as an event log or a flat file.

 

I followed all the steps mentioned in the link and succeeded in configuring the application to send message to Message Queuing through MSMQ trace listener, but distributor service is failing to forward the message to the trace listener. We configured the Logging application block in MsmqDistributor.config.exe (provided by Enterprise Library) where I add the Flat file to log entries.

 

I work around for this issue and created another project which reads message from Message Queuing and write to the log file, but my main aim is to use Logging application block under MsmqDistributor.config.exe and achieve the same task.

 

Any help will be appreciated.

 

Thanks,

Rupanshu

Mar 24, 2009 at 10:31 AM
To be honest, I haven't tried this before so while trying to follow the steps on How to Use the Distributor Service, could you check the event viewer if there's any error which could suggest
why the distributor service is failing?


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Mar 26, 2009 at 8:11 AM
I am not getting any error under event viewer.
The issue is : though i am getting message under Message Queuing block but is not getting forwarded further to mentioned log file.
Here Distributor service is failing does not mean that i am getting any error but it mean that messages does not get forwarded from Message Queue to Flat file which i configured in the MsmqDistributor.config.exe.

Please suggest.
Rupanshu
Mar 26, 2009 at 10:59 AM
I was able to setup the distributor service and it works fine for me.  Did you modify the MsmqDistributorService.exe.config?  Can you enumerate the modifications you made?


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Apr 6, 2009 at 11:27 AM
My MsmqDistributorService.exe.config looks like following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <section name="msmqDistributorSettings" type="Microsoft.Practices.EnterpriseLibrary.Logging.MsmqDistributor.Configuration.MsmqDistributorSettings, MsmqDistributor" />
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add source="Enterprise Library Logging" formatter="Binary 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" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.BinaryLogFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Binary Formatter" />
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#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="General">
        <listeners>
          <add name="Formatted EventLog 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>
  <msmqDistributorSettings msmqPath=".\Private$\entlibnew" queueTimerInterval="1000" serviceName="Enterprise Library Distributor Service" />
</configuration>
Apr 8, 2009 at 11:24 AM
What is the name of the category where your MSMQ trace listener is?  The same category name should also be present in your MSMQ distributor config. 


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