serilog/serilog — pull request #197 by joneal (2014-08-22 13:46:22+00:00)
Title: Added new EventLog parameter 'manageEventSource'.

By default, the EventLog sink will check for the existence of the 'source' Windows event log. If the 'source' event log does not exist, then the EventLogSink constructor will automatically create the Windows event log.

if (!System.Diagnostics.EventLog.SourceExists(source, machineName))
{
System.Diagnostics.EventLog.CreateEventSource(sourceData);
}

If the application is not running as administrator, then the System.Diagnostics.EventLog.SourceExists API call will throw a security exception. The using of new parameter 'manageEventSource' will allow a consumer of the EventLog sink to specify whether the EventLogSink constructor attempts to create the Windows event log source..or not. This new 'manageEventSource' property defaults to true so the EventLog sink will automatically continue to exhibit its default behavior while allowing the consume to override.

Tested in the Serilog.SmokeTest project. Also validated that setting 'manageEventSource' in the appSettings also works.