/// <summary> /// Takes a message or alert, and if logging is enabled, logs it to the database /// For logging exceptions, SysLog.LogException should be used to capture the details of the exception /// </summary> /// <param name="message">A general description of the message being logged</param> /// <param name="details">Detailed information about the message</param> /// <param name="messageType">The type of message being logged</param> /// <param name="messageSeverity">The severity of the message being logged</param> public static void LogMessage(string message, string details, MessageTypeEnum messageType, MessageSeverityEnum messageSeverity) { try { if (!AppLogic.AppConfigBool("System.LoggingEnabled")) { return; } if (!CommonLogic.StringInCommaDelimitedStringList("database", AppLogic.AppConfig("System.LoggingLocation"))) { return; } new SysLog { Message = System.Web.HttpUtility.HtmlEncode(Security.ScrubCCNumbers(message)), Details = System.Web.HttpUtility.HtmlEncode(Security.ScrubCCNumbers(details)), MessageType = messageType, MessageSeverity = messageSeverity }.Commit(); } catch // Never let logging crash the site! { return; } }
/// <summary> /// Takes a message or alert, and if logging is enabled, logs it to the database /// For logging exceptions, SysLog.LogException should be used to capture the details of the exception /// </summary> /// <param name="message">A general description of the message being logged</param> /// <param name="details">Detailed information about the message</param> /// <param name="messageType">The type of message being logged</param> /// <param name="messageSeverity">The severity of the message being logged</param> public static void LogMessage(string message, string details, MessageTypeEnum messageType, MessageSeverityEnum messageSeverity) { try // Never let logging crash the site! { string loggingLocation = AppLogic.AppConfig("System.LoggingLocation"); bool loggingEnabled = AppLogic.AppConfigBool("System.LoggingEnabled"); if (loggingEnabled && CommonLogic.StringInCommaDelimitedStringList("database", loggingLocation)) { SysLog logEntry = new SysLog(); logEntry.Message = Security.HtmlEncode(Security.ScrubCCNumbers(message)); logEntry.Details = Security.HtmlEncode(Security.ScrubCCNumbers(details)); logEntry.MessageType = messageType; logEntry.MessageSeverity = messageSeverity; logEntry.Commit(); } else { return; } } catch { return; } }