W
Wade
Hi all,
I've created a windows service that occasionally writes information into an
event log. I have the following function created in a class-library for the
windows service:
Public Shared Function WriteToEventLog(ByVal Entry As String, ByVal
AppName As String, _
ByVal EventType As EventLogEntryType, ByVal LogName As String) As
Boolean
Dim objEventLog As New EventLog
Try
'Register the App as an Event Source
If Not objEventLog.SourceExists(AppName) Then
objEventLog.CreateEventSource(AppName, LogName)
End If
objEventLog.Source = AppName
' WriteEntry is overloaded
objEventLog.WriteEntry(Entry, EventType)
Return True
Catch Ex As Exception
Return False
End Try
End Function
Additionally, here is the code I use to invoke this method:
WriteToEventLog(sbOutput.ToString, gstrServiceName, _
EventLogEntryType.Information, "System")
Everytime this runs, however, I get duplicate entries in my the event log.
Any thoughts as to why this is happening?
Thanks in advance,
Wade
I've created a windows service that occasionally writes information into an
event log. I have the following function created in a class-library for the
windows service:
Public Shared Function WriteToEventLog(ByVal Entry As String, ByVal
AppName As String, _
ByVal EventType As EventLogEntryType, ByVal LogName As String) As
Boolean
Dim objEventLog As New EventLog
Try
'Register the App as an Event Source
If Not objEventLog.SourceExists(AppName) Then
objEventLog.CreateEventSource(AppName, LogName)
End If
objEventLog.Source = AppName
' WriteEntry is overloaded
objEventLog.WriteEntry(Entry, EventType)
Return True
Catch Ex As Exception
Return False
End Try
End Function
Additionally, here is the code I use to invoke this method:
WriteToEventLog(sbOutput.ToString, gstrServiceName, _
EventLogEntryType.Information, "System")
Everytime this runs, however, I get duplicate entries in my the event log.
Any thoughts as to why this is happening?
Thanks in advance,
Wade