by Gehan Fernando. (13 Submissions)
Category: Windows System Services
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Mon 17th September 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Write To Windows Event Log ...
WriteToEventLog("Hello Where Are U", EventLogEntryType.Information, "VB.Net Application", "Application")
End Sub
Private Function WriteToEventLog(ByVal Entry As String, ByVal LogEntryType As System.Diagnostics.EventLogEntryType, _
Optional ByVal AppName As String = "VB.Net Application", _
Optional ByVal LogName As String = "Application") As Boolean
Dim objeventlog As New EventLog()
Try
If EventLog.SourceExists(AppName) = False Then
EventLog.CreateEventSource(AppName, LogName)
End If
objeventlog.Source = AppName
objeventlog.WriteEntry(Entry, LogEntryType)
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
objeventlog.Dispose()
End Try
End Function