Standard Sample code:
Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using system.windows.forms;using system.diagnostics;using System.diagnostics.eventing;namespace windowsformsapplication1{public partial class Form1:form {public Fo RM1 () {InitializeComponent (); private void Button1_Click (object sender, EventArgs e) {string LogName = "Nieweiking_log"; String SourceName = "nieweiking program"; if (! EventLog.SourceExists (SourceName)) {var eventsourcedata = new EventSourceCreationData (Sourcenam E, LogName); EventLog.CreateEventSource (Eventsourcedata); } using (var log = new EventLog (LogName, ".", SourceName)) {log. WriteEntry ("Message 1"); Log. WriteEntry ("Message 2", eventlogentrytype.warning);; Log. WriteentRy ("Message 2", eventlogentrytype.information, 33); } } }}
Write System program log information to Windows Log Manager