當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET EventSchemaTraceListener類代碼示例

本文整理匯總了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
開發者ID:VB.NET開發者,項目名稱:System.Diagnostics,代碼行數:40,代碼來源:EventSchemaTraceListener


注:本文中的System.Diagnostics.EventSchemaTraceListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。