示例#1
0
        private void _eventLogListener_LogWritten(RetrievedLog log)
        {
            var dict = new Dictionary <string, string>();

            dict.Add("Source", log.Source);
            _logger.ReportTraceAsync(log.Description, TraceSeverity.Error, dict);
        }
        /// <summary>
        /// Callback method that gets executed when an event is
        /// reported to the subscription.
        /// </summary>
        private void EventLogEventRead(object obj,
                                       EventRecordWrittenEventArgs arg)
        {
            // Make sure there was no error reading the event.
            if (arg.EventRecord != null)
            {
                if (LogWritten != null)
                {
                    var log = new RetrievedLog
                    {
                        Source      = arg.EventRecord.ProviderName,
                        DateTime    = arg.EventRecord.TimeCreated,
                        EventId     = arg.EventRecord.Id,
                        Description = arg.EventRecord.FormatDescription()
                    };

                    LogWritten(log);
                }
            }
            else
            {
                //"The event instance was null.";
            }
        }