public void ModifyOverflowPolicy(System.Diagnostics.OverflowAction action, int retentionDays)
 {
     this.m_underlyingEventLog.ModifyOverflowPolicy(action, retentionDays);
 }
示例#2
0
 public void ModifyOverflowPolicy(System.Diagnostics.OverflowAction action, int retentionDays)
 {
 }
示例#3
0
        public WindowsEventLogWriter(string eventLogName, string eventSourceName, string eventLogMachineName, bool createEventLog, System.Diagnostics.OverflowAction overflowAction, int retentionDays, ILogEventFormatter eventFormatter, ILogEventFilter filter) : base(filter)
        {
            eventLogName = eventLogName ?? "Application";
            if (String.IsNullOrWhiteSpace(eventLogName))
            {
                throw new ArgumentException(nameof(eventLogName) + " cannot be empty or whitespace.", nameof(eventLogName));
            }
            if (eventSourceName == null)
            {
                throw new ArgumentNullException(nameof(eventSourceName));
            }
            if (String.IsNullOrWhiteSpace(eventSourceName))
            {
                throw new ArgumentException(nameof(eventSourceName) + " cannot be empty or whitespace.", nameof(eventSourceName));
            }

            _EventFormatter  = eventFormatter;
            _EventLogName    = eventLogName;
            _EventSourceName = eventSourceName;

            if (createEventLog)
            {
                if (String.IsNullOrWhiteSpace(eventLogMachineName))
                {
                    eventLogMachineName = ".";
                }
                if (!System.Diagnostics.EventLog.SourceExists(eventSourceName, eventLogMachineName))
                {
                    var creationData = new System.Diagnostics.EventSourceCreationData(eventSourceName, eventLogName);
                    creationData.MachineName = eventLogMachineName;
                    System.Diagnostics.EventLog.CreateEventSource(creationData);

                    var log = new System.Diagnostics.EventLog(eventLogName, eventLogMachineName);
                    log.ModifyOverflowPolicy(overflowAction, retentionDays);
                }
            }

            _Log = new System.Diagnostics.EventLog(eventLogName, eventLogMachineName, eventSourceName);
        }