Language Basics C# Book

Fail() method from Debug and Trace class send message to TraceListener.
using System;
using System.Diagnostics;
class Program
{
static void Main()
{
Trace.Listeners.Add(new TextWriterTraceListener("trace.txt"));
Trace.Fail("File data.txt does not exist!");
}
}