Create TraceSource and trace events : TraceSource « Development « C# / CSharp Tutorial






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


public class MainClass
{
    public static void Main()
    {
        Trace.Listeners.Add(new ConsoleTraceListener());
        TraceSource customerTraceSource = new TraceSource("YourClassName");
        Trace.WriteLine("Instantiated a new customer {0}", "asdf");
        Debug.Assert(1 == 2, "1 ==2");
        customerTraceSource.TraceEvent(TraceEventType.Warning, 1000,"data might be corrupt");
    }
}








14.29.TraceSource
14.29.1.Create TraceSource and trace events
14.29.2.Create TraceSource and Trace Information
14.29.3.Create TraceSource and SourceSwitch: switch level