Couple of notes regarding the event log. First it requires Administrative privileges to create event log sources. Secondly, event log sources should be created before attempting to write to them. The MSDN documentation states that if you create
the event log source and attempt to write to it right away, it could result in event log corruption. The event log source requires a bit of time (a second or two?) to initialize itself.
To create event log source via PowerShell, you can use:
$machineName = '.'
[System.Diagnostics.EventLog]::CreateEventSource('My Application Source', 'Application', $machineName)
or from .NET code,
string sourceName = "My Application Source";
string logName = "Application";
string machineName = "."; // local machine
System.Diagnostics.EventLog.CreateEventSource( sourceName, logName, machineName);
Thanks for the replay..
My requirement is not like this : Creating the Event log is not using the code.
It should be from the conguration file using our own event log.