本文整理汇总了C#中System.Diagnostics.EventSchemaTraceListener类的典型用法代码示例。如果您正苦于以下问题:C# EventSchemaTraceListener类的具体用法?C# EventSchemaTraceListener怎么用?C# EventSchemaTraceListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventSchemaTraceListener类属于System.Diagnostics命名空间,在下文中一共展示了EventSchemaTraceListener类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
#define NOCONFIGFILE
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Diagnostics;
class testClass
{
[STAThreadAttribute]
static void Main()
{
File.Delete("TraceOutput.xml");
TraceSource ts = new TraceSource("TestSource");
#if NOCONFIGFILE
//ts.Listeners.Add(new EventSchemaTraceListener("TraceOutput.xml", "eventListener", 65536, TraceLogRetentionOption.LimitedCircularFiles, 20480000, 2));
ts.Listeners.Add(new EventSchemaTraceListener("TraceOutput.xml", "eventListener"));
ts.Listeners["eventListener"].TraceOutputOptions = TraceOptions.DateTime | TraceOptions.ProcessId | TraceOptions.Timestamp;
#endif
ts.Switch.Level = SourceLevels.All;
string testString = "<Test><InnerElement Val=\"1\" /><InnerElement Val=\"Data\"/><AnotherElement>11</AnotherElement></Test>";
UnescapedXmlDiagnosticData unXData = new UnescapedXmlDiagnosticData(testString);
ts.TraceData(TraceEventType.Error, 38, unXData);
ts.TraceEvent(TraceEventType.Error, 38, testString);
Trace.Listeners.Add(new EventSchemaTraceListener("TraceOutput.xml"));
Trace.Write("test", "test");
Trace.Flush();
ts.Flush();
ts.Close();
DisplayProperties(ts);
Process.Start("notepad.exe", "TraceOutput.xml");
Console.WriteLine("Press the enter key to exit");
Console.ReadLine();
}
private static void DisplayProperties(TraceSource ts)
{
Console.WriteLine("IsThreadSafe? " + ((EventSchemaTraceListener)ts.Listeners["eventListener"]).IsThreadSafe);
Console.WriteLine("BufferSize = " + ((EventSchemaTraceListener)ts.Listeners["eventListener"]).BufferSize);
Console.WriteLine("MaximumFileSize = " + ((EventSchemaTraceListener)ts.Listeners["eventListener"]).MaximumFileSize);
Console.WriteLine("MaximumNumberOfFiles = " + ((EventSchemaTraceListener)ts.Listeners["eventListener"]).MaximumNumberOfFiles);
Console.WriteLine("Name = " + ((EventSchemaTraceListener)ts.Listeners["eventListener"]).Name);
Console.WriteLine("TraceLogRetentionOption = " + ((EventSchemaTraceListener)ts.Listeners["eventListener"]).TraceLogRetentionOption);
Console.WriteLine("TraceOutputOptions = " + ((EventSchemaTraceListener)ts.Listeners["eventListener"]).TraceOutputOptions);
}
}