Thursday 1 December 2011

System EVENLOG for logging

if you are planning to use system even viewer for loging purpose. then,below piece of code will work for you!!

if(System.Diagnostics.EventLog.SourceExists("Application"))
   {
     this.eventLog.Source = "Application";
     this.eventLog.Log = "Application";
     this.eventLog.WriteEntry("This is Warning for evenlog!!", EventLogEntryType.Warning);
     this.eventLog.WriteEntry("This is Information for evenlog!!", EventLogEntryType.Information);
     this.eventLog.WriteEntry("This is Error for evenlog!!", EventLogEntryType.Error);
   }

below is the screen shot from event viewer with logging details.


Thanks,
Md. jawed

No comments: