When inserting log events, the TimeCreated field is not accurate enough

I am trying to register applications in a Windows event log in C # .net framework 4, but when I insert the log entries, the TimeCreated field (Event Viewer โ†’ Windows Logs โ†’ Application โ†’ -> Details โ†’ Friendly View โ†’ System) gets a value similar to

[SystemTime] 2012-03-28T11:07:12.000000000Z 

As you can see, the accuracy of the second second is absent, although I see some other event in the viewer, where there are numbers after the ".". with a more accurate timestamp.

Is this a kind of limitation of .Net Framework / CLR / C # or am I just doing something wrong?

Thanks.

VS2010SP1, Win7 / Server 2008 R2 Environment.

UPDATE:

I could mention that I tried with

 EventLog.WriteEntry("applicationName", "message", logEntryType, (int)eventId, (short)taskCategory); 

and log4net EventLogAppender.

UPDATE 2:

Thus, using ETW to insert events into the event log actually results in events in which SystemTime has secondary permission. Maybe this is actually necessary, it seems like an unnecessary case for my case.

+4
source share
2 answers

Finally, Microsoft provided a solution to this problem. Check out this blog post: NuGet EventSource Package Announcement - Write to the Windows event log .

+2
source

I canโ€™t find anything authoritative (unfortunately), but it seems that the advapi32.dll function of ReportEvent only tracks to the second. In the examples that I saw when using this function, the timestamp is, as you showed, only to the second.

The WriteEntry method uses the ReportEvent ADVAPI32.dll function to write to the event log, no date and time values โ€‹โ€‹are passed to this function, so we must assume that this is an internal thing that does not track accuracy.

+1
source

Source: https://habr.com/ru/post/1403875/


All Articles