Support > Samples > Coyote as TraceListener

Coyote as TraceListener

Download source code


This sample application demonstrates how to trace messages with the Coyote Core Framework with adapting the source code of an existing application.

Step 1:  Configure your application

To enable tracing in your application it's important to add the “traceManagement” section into your application configuration file. The following sample shows the necessary configuration to trace messages from Debug.Write().


<?xml version="1.0" encoding="utf-8" ?>
                Css.Diagnostics.TraceComLib" />
  <traceManagement mode="On">
      <publisher key="TraceSvrPublisher1" mode="On" 
          <attribute name="url" 
                     value="tcp://localhost:13400/TraceSvr.rem" />
          <filter type="*" level="4"></filter>
      <filter type="*" level="4"></filter>
        <trace autoflush="true" indentsize="2">
                <remove name="Default"/>
                <add name="TraceAgentTraceListener"
/> </listeners> </trace> </system.diagnostics> </configuration>
Step 2: Reference Css.Diagnostics.TraceComLib

The whole tracing technology is located in the “Css.Diagnostics.TraceComLib” Library. Referencing this Library in your application offers you the possibility to create and trace messages.

Step 3: Tracing

The following snippet shows a possible implementation to trace messages in your application by using the usual System.Diagnostics.Debug.Write() method.


using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.Remoting;

namespace Css.Coyote.Samples.TraceListener
    class Program
        static void Main(string[] args)
                    , AppDomain.CurrentDomain.SetupInformation.ConfigurationFile)
                    , true);

            Exception ex = new Exception("If you read this, everything works fine ;-)");

                throw ex;
            catch (Exception)
                Debug.Write(ex, "Exception");

            Console.WriteLine("Look at your Coyote Trace Monitor!");
Step4: Start Coyote Trace Monitor
Click: File - New - Run 
Step5: Start your application

Your Coyote Trace Monitor should display the exception you have traced: