Ejemplo n.º 1
0
 internal virtual void WriteEntryToEventLog(WindowsEventLogLoggingProvider provider,
                                            string eventLogMessage, EventLogEntryType type)
 {
     using (EventLog eventLog = CreateEventLog(provider))
     {
         eventLog.WriteEntry(eventLogMessage, type);
     }
 }
Ejemplo n.º 2
0
        private static EventLog CreateEventLog(WindowsEventLogLoggingProvider provider)
        {
            EventLog eventLog = new EventLog(provider.LogName);

            try
            {
                if (!EventLog.SourceExists(provider.Source))
                {
                    EventLog.CreateEventSource(provider.Source, provider.LogName);
                }

                eventLog.Source = provider.Source;
            }
            catch
            {
                eventLog.Dispose();
                throw;
            }

            return(eventLog);
        }