本文整理汇总了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();
}
}