using System.Diagnostic;EventLog myNewLog = new EventLog();
myNewLog.Log = "System Log";//或者是"Application Log" , "Security Log"                      
myNewLog.MachineName="你的计算机名";
foreach(EventLogEntry entry in myNewLog.Entries)
{
listBox1.Items.Add(entry.Message);
}    

解决方案 »

  1.   

    应用程序日志Application,系统日志System,安全日志Security
    写入日志:
    byte[] myByte=new byte[10];
    for(int i=0;i<10;i++)
    {
    myByte[i]= (byte)(i % 2);
    }
    // Write an informational entry to the event log.
    EventLog.WriteEntry("SecondSource","Writing warning to event log.", 
    EventLogEntryType.Error,123,1 ,myByte);
    读取日志:
    EventLog sample=new EventLog();
    sample.Log="Application";
    EventLogEntryCollection myCollection=sample.Entries;
    foreach(EventLogEntry test in myCollection) { Console.WriteLine(test.Message,test.Source,test.EventID); }
      

  2.   

    虽然我已经在msdn里查到了,不过还是非常感谢两位的回复:)
    thanks!