0

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,

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by venky9589
0

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);
            }

Edited by apegram: n/a

0

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.

0

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();
      }
    }
0

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 :(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.