I need to write to the "Application" folder in the Windows Event Log, specifically on Windows Server 2003. We have a scheduled task that checks the Application folder and sends out notification emails. I must write to that folder or else my custom error will not be picked up.
I created some code to do so but I did something wrong. My console app is instead created its own folder and is writing to "Repository Server Restart" instead. Initially I was writing to that folder so I changed the LOGNAME literal. It is still writing to that folder.
I need a fresh set of eyes to look at this code and tell me what I'm missing. Below is the code for this specific part of the console app.
Option Strict On
Const TIMEINTERVAL AsInteger = 100
Const LOGNAME AsString = "Application"'Repository Server Restart
Const LOGSOURCE AsString = "File Repository AutoRestart"
Const LOGENTRY AsString = "Input and Output Repository Servers Restarted"
Const EVENTID AsInteger = 18200
PrivateSub writeLog(ByVal source AsString, ByVal eventText AsString)
'Creates an entry in the event log
Dim sourceData AsEventSourceCreationData = NewEventSourceCreationData(source, LOGNAME)
sourceData.Source = source
If Not EventLog.SourceExists(source, Environment.MachineName) Then
End If'Not EventLog.SourceExists(source, Environment.MachineName)
EventLog.WriteEntry(source, eventText, EventLogEntryType.Warning, EVENTID)
End Sub'writeLog(ByVal source As String, ByVal eventText As String)