本文整理匯總了C#中System.Diagnostics.TextWriterTraceListener類的典型用法代碼示例。如果您正苦於以下問題:C# TextWriterTraceListener類的具體用法?C# TextWriterTraceListener怎麽用?C# TextWriterTraceListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TextWriterTraceListener類屬於System.Diagnostics命名空間,在下文中一共展示了TextWriterTraceListener類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
public class Sample
{
public static int Main(string[] args) {
// Create a file for output named TestFile.txt.
Stream myFile = File.Create("TestFile.txt");
/* Create a new text writer using the output stream, and add it to
* the trace listeners. */
TextWriterTraceListener myTextListener = new
TextWriterTraceListener(myFile);
Trace.Listeners.Add(myTextListener);
// Write output to the file.
Trace.Write("Test output ");
// Flush the output.
Trace.Flush();
return 0;
}
}
示例2: new TextWriterTraceListener(String fileName)
#define DEBUG
using System;
using System.Globalization;
using System.Diagnostics;
class MainClass
{
public static void Main()
{
TextWriterTraceListener tl = new TextWriterTraceListener("Example21_12.txt");
Debug.Listeners.Add(tl);
EventLogTraceListener t2 = new EventLogTraceListener("Application");
Debug.Listeners.Add(t2);
Debug.WriteLine("Starting Main()");
Debug.Assert(1 == 2, "1 ==2");
Debug.WriteLine("Exiting Main()");
Debug.Flush();
Debug.Close();
}
}