How to create a new event log using c#
private void WriteToEventLog(string message) { string newSource = "NewSource"; EventLog eventLog = new EventLog(); if (!EventLog.SourceExists(newSource)) { EventLog.CreateEventSource(newSource, newSource); } eventLog.Source = newSource; eventLog.EnableRaisingEvents = true; eventLog.WriteEntry(message); }
Call above method and pass the message
WriteToEventLog("This is the message that I want to show");
Then go to control panel ->Administrative tools -> Event Viewer You can view the new event log and click on that event log you can Information and click on the information to view the message.
Comments
Post a Comment