new TraceSource : TraceSource « System.Diagnostics « C# / C Sharp by API






new TraceSource

  

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");
    }
}

   
    
  








Related examples in the same category

1.TraceSource.Listeners.Add
2.TraceSource.Switch
3.TraceSource.TraceEvent
4.TraceSource.TraceInformation