The following code snippet shows how to create an Event log file in dotnet import the namespace
using System.Diagnostics;
public void LogFile(string strSource, string strLogName, string strEvent) { try { //condition for checking eventlog source existed or not if (!EventLog.SourceExists("DotnetApplications")) { //creating a event log EventLog.CreateEventSource("Applications", "DotnetApplications"); } //writing eventlog files EventLog.WriteEntry(strSource, strEvent); EventLog.WriteEntry(strSource, strEvent, EventLogEntryType.Warning, 2821);
} //throws a exception if any error occurs in try block catch (Exception ex) { objException.ExceptionHandling(strMethod, strQueryStringArr, "", ex.Message, ""); LogFile("Applications", "DotnetApplications", ex.Message); } }
|
No responses found. Be the first to respond and make money from revenue sharing program.
|