Posts

Showing posts with the label Create Event Log in C#

write Logs into Windows Event in C#

Here is the code you can use; /// /// It manages logging policy. /// use app.config of the dll to clarify debug.print logging will be used. /// default value = true /// /// caller Application Name /// Log Name /// localhost /// use additional Debug.Print Logs, every time logging occur public AdvanceLogging(string strSourceName, string strLogName, string strMachineName, bool useDebugPrint) { Microsoft.Win32.RegistryKey registrykeyLM = null; Microsoft.Win32.RegistryKey registrykeyEventlog = null; Microsoft.Win32.RegistryKey registrykeyKey = null; try { //--- Check to see that event log name exists, if so... if (System.Diagnostics.EventLog.Exists(StrLogName)) { //--- Check to see if the source exists, if not... if (!System.Diagnostics.EventLog