/// <summary> /// Initializes a new instance of the <see cref="EventLogLogger"/> class. /// </summary> /// <param name="name">The name of the logger.</param> /// <param name="settings">The <see cref="EventLogSettings"/>.</param> public EventLogLogger(string name, EventLogSettings settings) { _name = string.IsNullOrEmpty(name) ? nameof(EventLogLogger) : name; _settings = settings; var logName = string.IsNullOrEmpty(settings.LogName) ? "Application" : settings.LogName; var sourceName = string.IsNullOrEmpty(settings.SourceName) ? "Application" : settings.SourceName; var machineName = string.IsNullOrEmpty(settings.MachineName) ? "." : settings.MachineName; // Due to the following reasons, we cannot have these checks either here or in IsEnabled method: // 1. Log name & source name existence check only works on local computer. // 2. Source name existence check requires Administrative privileges. _eventLog = new System.Diagnostics.EventLog(logName, machineName, sourceName); }
/// <summary> /// Initializes a new instance of the <see cref="EventLogLoggerProvider"/> class. /// </summary> /// <param name="settings">The <see cref="EventLogSettings"/>.</param> public EventLogLoggerProvider(EventLogSettings settings) { _settings = settings; }