Question

i created an eventlog entry:

if (!EventLog.SourceExists("testeventlog"))
            EventLog.CreateEventSource("testeventlog","testeventlog");

EventLog.WriteEntry("testeventlog", "testevent");

After this i tried to read out the time generated:

eLog = new EventLog("testeventlog");
foreach (EventLogEntry entry in eLog.Entries)
{

     entry.TimeGenerated.ToString("MM/dd/yyyy hh:mm:ss.fff tt");

}

My Problem is that the Milliseconds are 0 every time. Is there any possibility to write an eventlogentry in which the milliseconds are saved, too?

Was it helpful?

Solution

EventLog does not store time at millisecond resolution. Generally, it should not be needed, because you should not write to it so often. If you need a log with higher resolution and custom messages, consider using a framework like NLog or Log4Net and writing messages to a file or db.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top