Below is the Utility function used to log the message in Microsoft Windows Operating Systems.
class Program { static void Main(string[] args) { LogMessage("ShivaSoftBlog - Error Message", EventLogEntryType.Error); LogMessage("ShivaSoftBlog - Failure Audit Message", EventLogEntryType.FailureAudit); LogMessage("ShivaSoftBlog - Information Message", EventLogEntryType.Information); LogMessage("ShivaSoftBlog - Success Audit Message", EventLogEntryType.SuccessAudit); LogMessage("ShivaSoftBlog - Warning Message", EventLogEntryType.Warning); Console.WriteLine("LOg Success"); Console.Read(); } private static void LogMessage(string message, EventLogEntryType logType) { if (!EventLog.SourceExists("ShivaSoftBlog")) EventLog.CreateEventSource("ShivaSoftBlog", "Application"); EventLog ncsLog = new EventLog(); ncsLog.Source = "ShivaSoftBlog"; ncsLog.WriteEntry(message, logType); } }
Leave a Reply