本文整理匯總了VB.NET中System.Diagnostics.EventSchemaTraceListener類的典型用法代碼示例。如果您正苦於以下問題:VB.NET EventSchemaTraceListener類的具體用法?VB.NET EventSchemaTraceListener怎麽用?VB.NET EventSchemaTraceListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了EventSchemaTraceListener類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: testClass
#Const NOCONFIGFILE = True
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Imports System.Diagnostics
Class testClass
<STAThreadAttribute()> _
Shared Sub Main()
File.Delete("TraceOutput.xml")
Dim ts As New TraceSource("TestSource")
#If NOCONFIGFILE Then
ts.Listeners.Add(New EventSchemaTraceListener("TraceOutput.xml", "eventListener", 65536, TraceLogRetentionOption.LimitedCircularFiles, 20480000, 2))
ts.Listeners("eventListener").TraceOutputOptions = TraceOptions.DateTime Or TraceOptions.ProcessId Or TraceOptions.Timestamp
#End If
ts.Switch.Level = SourceLevels.All
Dim testString As String = "<Test><InnerElement Val=""1"" /><InnerElement Val=""Data""/><AnotherElement>11</AnotherElement></Test>"
Dim unXData As New UnescapedXmlDiagnosticData(testString)
ts.TraceData(TraceEventType.Error, 38, unXData)
ts.TraceEvent(TraceEventType.Error, 38, testString)
ts.Flush()
ts.Close()
DisplayProperties(ts)
Process.Start("notepad.exe", "TraceOutput.xml")
Console.WriteLine("Press the enter key to exit")
Console.ReadLine()
End Sub
Private Shared Sub DisplayProperties(ByVal ts As TraceSource)
Console.WriteLine("IsThreadSafe? " + CType(ts.Listeners("eventListener"), EventSchemaTraceListener).IsThreadSafe.ToString())
Console.WriteLine("BufferSize = " + CType(ts.Listeners("eventListener"), EventSchemaTraceListener).BufferSize.ToString())
Console.WriteLine("MaximumFileSize = " + CType(ts.Listeners("eventListener"), EventSchemaTraceListener).MaximumFileSize.ToString())
Console.WriteLine("MaximumNumberOfFiles = " + CType(ts.Listeners("eventListener"), EventSchemaTraceListener).MaximumNumberOfFiles.ToString())
Console.WriteLine("Name = " + CType(ts.Listeners("eventListener"), EventSchemaTraceListener).Name)
Console.WriteLine("TraceLogRetentionOption = " + CType(ts.Listeners("eventListener"), EventSchemaTraceListener).TraceLogRetentionOption.ToString())
Console.WriteLine("TraceOutputOptions = " + CType(ts.Listeners("eventListener"), EventSchemaTraceListener).TraceOutputOptions.ToString())
End Sub
End Class