문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top