.net中使用EventLog控件可以方便的控制和访问日志信息。
form1设计如图所示:
form1代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace logDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.eventLog1.Log = "System";
EventLogEntryCollection collection = eventLog1.Entries;
int Count = collection.Count;
string info = "显示系统日志"+C