Function to Write to Application Event Log using VB.Net

Public Function WriteToEventLog(ByVal Entry As String)

Dim appName As String = “Your Application”
Dim eventType As EventLogEntryType = EventLogEntryType.Error
Dim logName = “Application”

Dim objEventLog As New EventLog()


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