/// <summary> /// Checks if the level of the message is set to be logged /// </summary> /// <returns>True means proceed with logging</returns> public static bool CheckLoggingLevel(LogManager.EventLevel level ) { if (Settings.Instance.CurrentLoggingLevel >= level || Settings.Instance.CurrentLoggingLevel == EventLevel.All) { return true; } else { return false; } //Future: Also want to include or exclude based on namespace }
/// <summary> /// Log event while specifying the log level manually /// </summary> /// <param name="level"></param> /// <param name="eventLog">The object for saving the event information</param> /// <param name="methodBase">The calling method, used for reflection</param> /// <param name="Message">Manual Message provided to the method</param> /// <param name="ob">Array of objects to set the parameters for on the event log object</param> public static void WriteLogEvent(LogManager.EventLevel level, IEventLog eventLog, MethodBase methodBase, string Message, params object[] ob) { if (CheckLoggingLevel(level)) { // get the method name eventLog.MethodName = methodBase.Name.ToString(); // Get the name of the class that is calling eventLog.ClassName = methodBase.Module.ToString(); SetAttributeValues(eventLog, ob); //Set the values on the call object eventLog.Save(); } }