Windows service making duplicate event log entries.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top