writing to Windows Event logs in VB.Net 2010

I am having difficulty in writing to the windows event logs. I am specifically trying to write to the application log.

The test code I am working with is;

       Dim sSource As String
        Dim sLog As String
        Dim sEvent As String
        Dim sMachine As String

        sSource = "dotNET Sample App"
        sLog = "Application"
        sEvent = "Sample Event"
        sMachine = "."

        If Not EventLog.SourceExists(sSource, sMachine) Then
            EventLog.CreateEventSource(sSource, sLog, sMachine)
        End If

        Dim ELog As New EventLog(sLog, sMachine, sSource)
        ELog.WriteEntry(sEvent, EventLogEntryType.Warning, 234, CType(3, Short))

some of the code is identified as being obsolete, unfortunatly I cannot find documentation at MSDN for the replacement code.  Further there is an issue with a system.securityexception
Who is Participating?
Alex_WConnect With a Mentor Commented:
It looks like the obeolete method is EventLog.CreateEventSource() with the overload of 3 arguments.  You may want to try with two string arguments.

AlyantoAuthor Commented:
Hi Alex
I have tried what is within the article unfortunatly I am still getting the same result.  I am also getting an issue with security access rights.  I think if I can find the current object/code I could eliminate that from the issue.  I am currently working on Windows 7 and the server that will eventually host the application will be Windows Server 2008 R2

Any and all ideas are most welcome.

AlyantoAuthor Commented:
Cheers :)

This solved the issue in the question,  I will place a second question that keys onto the issue of running the scheduler and security needs.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.