Event Log : Event Log « Windows System « VB.Net






Event Log

  
Public Class MainClass
    Public Shared Function WriteToEventLog(ByVal Entry As String, _
        Optional ByVal AppName As String = "AAA", Optional ByVal EventType As EventLogEntryType = EventLogEntryType.Information, Optional ByVal LogName As String = "Application") As Boolean
        Dim objEventLog As New EventLog()
        Try
            If Not EventLog.SourceExists(AppName) Then
                EventLog.CreateEventSource(AppName, LogName)
            End If
            objEventLog.Source = AppName
            objEventLog.WriteEntry(Entry, EventType)
            Return True
        Catch Ex As Exception
            Return False
        End Try
    End Function
    Public Shared Sub Main()
        WriteToEventLog("11111")
        WriteToEventLog("message", "Authenticator", EventLogEntryType.Error, "Special Log")
    End Sub
End Class

   
    
  








Related examples in the same category

1.Event Log: create event source and displayEvent Log: create event source and display