Create the source MySource if it does not already exist, and writes an entry to the event log MyNewLog. : EventLog « Windows « VB.Net Tutorial






Option Explicit
Option Strict

Imports System
Imports System.Diagnostics
Imports System.Threading

Class MySample
    Public Shared Sub Main()

        If Not EventLog.SourceExists("MySource") Then
            EventLog.CreateEventSource("MySource", "MyNewLog")
            Console.WriteLine("CreatingEventSource")
            Return
        End If
        Dim myLog As New EventLog()
        myLog.Source = "MySource"
        myLog.WriteEntry("Writing to event log.")
    End Sub
End Class








24.12.EventLog
24.12.1.Write to System EventLog
24.12.2.Display all Application EventLog
24.12.3.EventLogEntryType.Information
24.12.4.Deletes a log from the specified computer
24.12.5.Create the source MySource if it does not already exist, and writes an entry to the event log MyNewLog.