Write Message to system event log : Event Log : Windows C# Source Code


Custom Search

C# Source Code » Windows » Event Log »

 

Write Message to system event log









    


  using System;
  using System.Resources;
  using System.Drawing;
  using System.Collections;
  using System.Windows.Forms;
  using System.Resources;
  using Microsoft.Win32;

  // For event log.
  using System.Diagnostics;
  class Test
  {
    static void Main(string[] args)
    {
      EventLog log = new EventLog();
      log.Log = "Application";
      log.Source = "www.navioo.com";
      log.WriteEntry("message from my own exa,ple...");
      
      // Display the first 5 entries in the Application log.
      for(int i = 0; i < 5; i++)
      {
                Console.WriteLine("Message: " + log.Entries[i].Message + "\n" +  
            "Box: " + log.Entries[i].MachineName + "\n" +
            "App: " + log.Entries[i].Source + "\n" +
            "Time entered: " + log.Entries[i].TimeWritten, 
            "Application Log entry:");
      }
      log.Close();
    }
  }
   
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Windows
» Event Log