Example #1
0
        /// <summary>
        /// Writes a simple debug statement with no other data saved.  
        /// </summary>
        /// <param name="eventLog">The object used to save the data</param>
        /// <param name="methodBase">The calling methods information for reflection</param>
        /// <param name="Message">A manually set message</param>
        public static void WriteDebugEvent(IEventLog eventLog, MethodBase methodBase, string Message)
        {
            if (CheckLoggingLevel(EventLevel.Debug))
            {
                // get the method name
                eventLog.MethodName = methodBase.Name.ToString();
                // Get the name of the class that is calling
                eventLog.ClassName = methodBase.Module.ToString();

                eventLog.EventLevel = LogManager.EventLevel.Debug;

                //Only the main information will be logged here since this is typically called by a static method                     
                eventLog.Save();
            }  
        }
Example #2
0
        /// <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();
            }
        }
Example #3
0
        /// <summary>
        /// Log a Critical error event with parameters from the object array added
        /// </summary>
        /// <param name="eventLog"></param>
        /// <param name="methodBase"></param>
        /// <param name="exp"></param>
        /// <param name="ob">Array of objects to set the parameters for on the event log object</param>
        public static void WriteCriticalErrorEvent(IEventLog eventLog, MethodBase methodBase, Exception exp, params object[] ob)
        {
            if (CheckLoggingLevel(EventLevel.CriticalError))
            {
                // get the method name
                eventLog.MethodName = methodBase.Name.ToString();
                // Get the name of the class that is calling
                eventLog.ClassName = methodBase.Module.ToString();

                eventLog.EventLevel = LogManager.EventLevel.CriticalError;

                eventLog.ExceptionData = exp.Data.ToString();

                eventLog.Message = exp.Message;

                SetAttributeValues(eventLog, ob);

                eventLog.Save();
            }
        }