Fork me on GitHub

c# 查询本机日志

代码
StringBuilder sb = new StringBuilder();
EventLog mylog
= new EventLog();
mylog.Log
= "Application"; // System[系统日志] | Application[应用日志] | Security[安全日志]
EventLogEntryCollection myCollection = mylog.Entries;
for (int i = 0; i < myCollection.Count; i++)
{
sb.Append(
"Time:" + myCollection[i].TimeGenerated + " " +
myCollection[i].Message
+ "<br />");
}

 

posted @ 2011-01-11 16:08  磊哥|www.javacn.site  阅读(626)  评论(0编辑  收藏  举报