private static void WRITE_Errors_To_EventLog(string MethodInCode, string msg, LogSeverity LogSeverity, EventID eventID = 0) { ErrorLogging_Level(); string err_msg = "DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SourceComputer=" + Settings.ComputerName + " Severity=" + Severity_Levels[(int)LogSeverity] + " MethodInCode=" + MethodInCode + " Message=" + msg + "\n"; if (LogSeverity == LogSeverity.Informataion) { EventLog_SWELF.WRITE_Info_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } else if (LogSeverity == LogSeverity.Verbose) { EventLog_SWELF.WRITE_Verbose_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } else if (LogSeverity == LogSeverity.Warning) { EventLog_SWELF.WRITE_Warning_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } else if (LogSeverity == LogSeverity.FailureAudit) { EventLog_SWELF.WRITE_FailureAudit_Error_To_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } else if (LogSeverity == LogSeverity.Critical) { EventLog_SWELF.WRITE_ERROR_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } else { EventLog_SWELF.WRITE_Verbose_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } }
internal static void WRITE_Errors_To_Log(string MethodInCode, string msg, LogSeverity LogSeverity, EventID eventID = 0) { ErrorLogging_Level(); if (Logging_Level_To_Report >= (int)LogSeverity) { string err_msg = "DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SourceComputer=" + Settings.ComputerName + " Severity=" + Severity_Levels[(int)LogSeverity] + " MethodInCode=" + MethodInCode + " Message=" + msg + "\n"; if (File_Operation.CHECK_if_File_Exists(Settings.GET_ErrorLog_Location)) { File.AppendAllText(Settings.GET_ErrorLog_Location, err_msg); } else { File.Create(Settings.GET_ErrorLog_Location).Close(); File.AppendAllText(Settings.GET_ErrorLog_Location, err_msg); } if (LogSeverity == LogSeverity.Informataion) { EventLog_SWELF.WRITE_Info_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } else if (LogSeverity == LogSeverity.Verbose) { EventLog_SWELF.WRITE_Verbose_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } else if (LogSeverity == LogSeverity.Warning) { EventLog_SWELF.WRITE_Warning_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } else if (LogSeverity == LogSeverity.FailureAudit) { EventLog_SWELF.WRITE_FailureAudit_Error_To_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } else if (LogSeverity == LogSeverity.Critical) { EventLog_SWELF.WRITE_ERROR_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } else { EventLog_SWELF.WRITE_Verbose_EventLog("DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SWELF Immediate" + " Severity=" + Severity_Levels[(int)LogSeverity] + " Message=" + err_msg + "\n", eventID); } File_Operation.CHECK_File_Size(Settings.GET_ErrorLog_Location); } }
private static void WRITE_Errors_To_Log(string msg, LogSeverity LogSeverity, EventID eventID = 0) { if (File_Operation.CHECK_if_File_Exists(Settings.GET_ErrorLog_Location)) { File.AppendAllText(Settings.GET_ErrorLog_Location, msg); } else { File.Create(Settings.GET_ErrorLog_Location).Close(); File.AppendAllText(Settings.GET_ErrorLog_Location, msg); } File_Operation.CHECK_File_Size(Settings.GET_ErrorLog_Location); if (LogSeverity == LogSeverity.Informataion) { EventLog_SWELF.WRITE_Info_EventLog(msg, eventID); } else if (LogSeverity == LogSeverity.Verbose) { EventLog_SWELF.WRITE_Verbose_EventLog(msg, eventID); } else if (LogSeverity == LogSeverity.Warning) { EventLog_SWELF.WRITE_Warning_EventLog(msg, eventID); } else if (LogSeverity == LogSeverity.FailureAudit) { EventLog_SWELF.WRITE_FailureAudit_Error_To_EventLog(msg, eventID); } else if (LogSeverity == LogSeverity.Critical) { EventLog_SWELF.WRITE_ERROR_EventLog(msg, eventID); } else { EventLog_SWELF.WRITE_Verbose_EventLog(msg, eventID); } }