Запись данных в системный журнал

Функция на C# для записи данных программы в системный журнал.

public bool WriteEvent(string sEntry, string sAppName, EventLogEntryType eEventType, string sLogName)
{
 EventLog oEventLog = new EventLog();
 try {
 //Register the Application as an Event Source
 if (!EventLog.SourceExists(sAppName))
 {
 EventLog.CreateEventSource(sAppName, sLogName);
 }
 //log the entry
 oEventLog.Source = sAppName;
 oEventLog.WriteEntry(sEntry, eEventType);
 return true;
 }
 catch (Exception Ex) {
 MessageBox.Show(Ex.Message);
 return false;
 }
}

Поблагодарить автора

Оставить комментарий

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>