Cannot get MSMQ TraceListener to work

Topics: Logging Application Block
Dec 11, 2008 at 4:03 PM
Edited Dec 11, 2008 at 6:57 PM
I am working with the LAB and trying to send messages to the Message Queue. My end goal is to use the Distributor service for logging. However, I can't even get a test program to send test messages to my private message queue(on local machine). No errors are being thrown in the code.

Here is the code I am using:

 LogEntry log = new LogEntry();
 log.EventId = 300;
 log.Message = txtMessage.Text;
 log.Categories.Add("DEBUG");
 log.Priority = 5;
 Logger.Write(log);

The App.config is:

<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" />
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add name="Msmq TraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.MsmqTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.MsmqTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" queuePath="FormatName:direct=os:L1068839\private$\test"
        formatter="Binary Formatter" messagePriority="Normal" timeToReachQueue="49710.06:28:15"
        timeToBeReceived="49710.06:28:15" recoverable="false" useAuthentication="false"
        useDeadLetterQueue="false" useEncryption="false" transactionType="None" />
    </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" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="DEBUG">
        <listeners>
          <add name="Msmq TraceListener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events">
        <listeners>
          <add name="Msmq TraceListener" />
        </listeners>
      </allEvents>
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings" />
    </specialSources>
  </loggingConfiguration>
</configuration>

Dec 12, 2008 at 2:43 AM
Hi,

Have you installed Message Queuing Service and the Distributor Service? Is the Distributor Service up and running?

Installing Distributor Service : 
http://msdn.microsoft.com/en-us/library/dd203267.aspx


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Dec 12, 2008 at 3:06 PM
Thank you for your response.

I was able to solve the problem last night. The TransactionType attribute in App.config defaults to "None" and my private queue was transactional. So I set the TransactionType to "Single" and everything worked fine. The Distributor service was also installed and started working after I made change.