S
S
Satisfied IT2019-02-21 20:47:52
C++ / C#
Satisfied IT, 2019-02-21 20:47:52

Reading the event log, why are not all events read correctly?

I needed to read the system logs, for the experiment I used the following code:

EventLog myEventLog = new EventLog("System", "localhost");
int i = 0;
foreach (EventLogEntry entry in myEventLog.Entries)
{
    richTextBoxLog.Text += "Category\n" + entry.Category + "\nCategoryNumber\n" +
                    entry.CategoryNumber + "\nEntryType\n" + entry.EntryType + "\nEventID\n" +
                    entry.EventID + "\nIndex\n" + entry.Index + "\nInstanceId\n" +
                    entry.InstanceId + "\nMachineName\n" + entry.MachineName +
                    "\nMessage\n" + entry.Message + "\nSource\n" + entry.Source;
    i++;
    if (i>10) break;
}

I noticed something strange in the toga, if the event source is the event EventLogtext in the system log and the one received by the program is the same, for example Запущена служба журнала событий., but if the event source is, for example, Microsoft-Windows-Kernel-Generalthen the program receives the following event text:
Не найдено описание для события с кодом '12' в источнике 'Microsoft-Windows-Kernel-General'.  Возможно, на локальном компьютере нет нужных данных реестра или файлов сообщений DLL для отображения сообщений, либо у вас нет прав доступа к ним.  В записи события содержится следующая информация:'10', '0', '17763', '1', '0', '0', '2019-02-17T12:23:00.500000000Z'
but if this event is viewed through the event log (eventvwr.msc), then we see
Системное время запуска операционной системы: ‎2019‎-‎02‎-‎17T12:23:00.500000000Z.
Why and how to get the same text as in the event log?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question