hey,
my name is venkatesh and m an final yr information science student.
i needed some help for ma project.I wanted to know how can i access all the errors generated by the OS.I wanted to make an .NET application that reads out all those errors..do you think its possible???
please help....

thank u,

Recommended Answers

All 4 Replies

You may want to explore the System.Diagnostics.EventLog class.

Sample:

System.Diagnostics.EventLog[] logs = EventLog.GetEventLogs();

            foreach (EventLog log in logs)
            {
                foreach (EventLogEntry entry in log.Entries)
                    Console.WriteLine(entry.Message);
            }

You may want to explore the System.Diagnostics.EventLog class.

Sample:

System.Diagnostics.EventLog[] logs = EventLog.GetEventLogs();

            foreach (EventLog log in logs)
            {
                foreach (EventLogEntry entry in log.Entries)
                    Console.WriteLine(entry.Message);
            }

hey thanx :)
Now using this code i can access all the errors and warnings invoked by the OS right.i wanted to make the system interacting rather than just giving msgs thru some boxes.

Also be sure to clean up after yourself. System.Diagnostics.EventLog implements IDisposable

private void button1_Click(object sender, EventArgs e)
    {
      System.Diagnostics.EventLog[] logs = System.Diagnostics.EventLog.GetEventLogs();
      foreach (System.Diagnostics.EventLog log in logs)
      {
        foreach (System.Diagnostics.EventLogEntry entry in log.Entries)
        {
          Console.WriteLine(entry.Message);
        }
      }
      //Clean up
      foreach (System.Diagnostics.EventLog log in logs)
      {
        log.Dispose();
      }
    }

Also be sure to clean up after yourself. System.Diagnostics.EventLog implements IDisposable

private void button1_Click(object sender, EventArgs e)
    {
      System.Diagnostics.EventLog[] logs = System.Diagnostics.EventLog.GetEventLogs();
      foreach (System.Diagnostics.EventLog log in logs)
      {
        foreach (System.Diagnostics.EventLogEntry entry in log.Entries)
        {
          Console.WriteLine(entry.Message);
        }
      }
      //Clean up
      foreach (System.Diagnostics.EventLog log in logs)
      {
        log.Dispose();
      }
    }

thank you it was very helpful but
am getting exceptions for dis code :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.