EventLog.WriteEntry(source, message) does not write to source

J

Jacob

I have the following code in a class...

---------------------------------------------------------------------------------
....
Private _eL As EventLog = Nothing
Private _eLName As String = My.Settings.EventLogName
Private _sourceName As String

Private Sub New()
' Require user passes source name.
End Sub
Public Sub New(ByVal EventSourceName As String)
_eL = New EventLog(_eLName, My.Computer.Name, EventSourceName)

' This will ensure that the event source is registered w/ the EMSL
event log.
If EventLog.LogNameFromSourceName(EventSourceName,
My.Computer.Name).Trim.Length > 0 _
And EventLog.LogNameFromSourceName(EventSourceName, My.Computer.Name)
<> _eL.Log Then
EventLog.DeleteEventSource(EventSourceName, My.Computer.Name)
End If

_eL.CreateEventSource(EventSourceName, _eL.Log, My.Computer.Name)
_sourceName = EventSourceName
End Sub
....
Public Sub WriteEvent(ByVal Message As String, ByVal EventType As
EventLogEntryType, Optional ByVal ID As Integer = 68)
EventLog.WriteEntry(_sourceName, Message, EventType, ID)
End Sub

....
---------------------------------------------------------------------------------

The eventlog gets created, but the events are always written to the
Application eventlog.

Please, help.

Thanks,
Jacob
 

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

Top