I am attempting to create my own custom event log using the below code:
if (!System.Diagnostics.EventLog.SourceExists("DataStream"))
{
EventLog.CreateEventSource("DataStream", "SIRsDetectionDataStreamLog");
}
logger = new EventLog();
logger.Source = "DataStream";
However, I keep getting a security error when checking if the source exists. The error I get is as follows:
SecurityException was unhandled
An unhandled exception of type 'System.Security.SecurityException' occurred in System.dll
Additional information: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
To create an event source you must have administrative privileges.
All event logs, including the security log, must be searched to determine whether the event source is unique. Non administrative users do not have permission to access the security log therefore a SecurityException is thrown.