Пример #1
0
        /// <summary>
        /// Create a log message at the Error log level. Message is exception.Message
        /// </summary>
        /// <param name="exception">Exception to write to Error log</param>
        /// <returns>Created message that was submitted to log store</returns>
        public LogMessage Error(Exception exception)
        {
            try
            {
                LogMessage msg = new LogMessage();

                if (IsErrorEnabled == false) return null;

                msg.RuntimeContext = new RuntimeContext(RuntimeContextOptions.HttpRequestContext | RuntimeContextOptions.MachineContext);
                msg.Severity = MessageLevel.Error;
                msg.MessageText = exception.Message;
                msg.AddException(exception);
                if (OnLogErrorEventHandler != null) OnLogErrorEventHandler(msg);
                return msg;
            }
            catch (Exception ex) //never throw an exception from log handler
            {
                Log.LastChanceLog(ex);
                return null;
            }
        }
Пример #2
0
        /// <summary>
        /// Create a log message at the Error log level
        /// </summary>
        /// <param name="messageText">Text to write to Error log.  May contain string.format({0}) arguments</param>
        /// <param name="messageNumber">Numerical index associated with this message</param>
        /// <param name="args">Arguments to pass to messageText</param>
        /// <param name="exception">Exception that is associated with this message</param>
        public LogMessage Error(Exception exception, string messageNumber,string messageText, params object[] args)
        {
            LogMessage msg = new LogMessage();
            try
            {
                if (IsErrorEnabled == false) return null;

                msg.RuntimeContext = new RuntimeContext(RuntimeContextOptions.HttpRequestContext | RuntimeContextOptions.MachineContext);
                msg.Severity = MessageLevel.Error;
                msg.MessageText = TextUtils.StringFormat(messageText, args);
                msg.MessageCode = messageNumber;
                msg.AddException(exception);
                if (OnLogErrorEventHandler != null) OnLogErrorEventHandler(msg);
            }

            catch (Exception ex)
            {
                Log.LastChanceLog(ex);

            }
            return msg;
        }
Пример #3
0
        /// <summary>
        /// Create a log message at the Information log level.
        /// </summary>
        /// <param name="exception">Exception to write to Information log</param>
        /// <param name="messageText">Text to write to Information log.  May contain string.format({0}) arguments</param>
        /// <param name="args">Arguments to pass to messageText</param>   
        public LogMessage Information(Exception exception, string messageText, params object[] args)
        {
            LogMessage msg = new LogMessage();
            try
            {
                if (IsInformationEnabled == false) return null;

                msg.Severity = MessageLevel.Information;
                msg.MessageText = TextUtils.StringFormat(messageText, args);
                msg.AddException(exception);
                if (OnLogInformationEventHandler != null) OnLogInformationEventHandler(msg);
            }

            catch (Exception ex)
            {
                Log.LastChanceLog(ex);

            }
            return msg;
        }
Пример #4
0
        /// <summary>
        /// Create a log message at the Warning log level. Message is exception.Message
        /// </summary>
        /// <param name="exception">Exception to write to Warning log</param>
        /// <param name="messageNumber">Numerical index associated with this message</param>
        /// <returns>Created message that was submitted to log store</returns>
        public LogMessage Warning(Exception exception, string messageNumber)
        {
            LogMessage msg = new LogMessage();
            try
            {
                if (IsWarningEnabled == false) return null;


                msg.RuntimeContext = new RuntimeContext(RuntimeContextOptions.HttpRequestContext | RuntimeContextOptions.MachineContext);
                msg.Severity = MessageLevel.Warning;
                msg.MessageText = exception.Message;
                msg.AddException(exception);
                msg.MessageCode = messageNumber;
                if (OnLogWarningEventHandler != null) OnLogWarningEventHandler(msg);
            }
            catch (Exception ex)
            {
                Log.LastChanceLog(ex);

            }
            return msg;
        }
Пример #5
0
        /// <summary>
        /// Create a log message at the Information log level. Message is exception.Message
        /// </summary>
        /// <param name="exception">Exception to write to Information log</param>
        /// <param name="messageNumber">Numerical index associated with this message</param>
        /// <returns>Created message that was submitted to log store</returns>
        public LogMessage Information(Exception exception, string messageNumber)
        {
            LogMessage msg = new LogMessage();
            try
            {
                if (IsInformationEnabled == false) return null;


                msg.Severity = MessageLevel.Information;
                msg.MessageText = exception.Message;
                msg.AddException(exception);
                msg.MessageCode = messageNumber;
                if (OnLogInformationEventHandler != null) OnLogInformationEventHandler(msg);
            }

            catch (Exception ex)
            {
                Log.LastChanceLog(ex);

            }
            return msg;
        }
Пример #6
0
        /// <summary>
        /// Create a log message at the Trace log level. Message is exception.Message
        /// </summary>
        /// <param name="exception">Exception to write to Trace log</param>
        /// <returns>Created message that was submitted to log store</returns>
        public LogMessage Trace(Exception exception)
        {
            LogMessage msg = new LogMessage();
            try
            {
                if (IsTraceEnabled == false) return null;


                msg.Severity = MessageLevel.Trace;
                msg.MessageText = exception.Message;
                msg.AddException(exception);
                if (OnLogTraceEventHandler != null) OnLogTraceEventHandler(msg);
            }

            catch (Exception ex)
            {
                Log.LastChanceLog(ex);

            }
            return msg;

        }
Пример #7
0
        /// <summary>
        /// Create a log message at the Debug log level.
        /// </summary>
        /// <param name="exception">Exception to write to Debug log</param>
        /// <param name="messageText">Text to write to debug log.  May contain string.format({0}) arguments</param>
        /// <returns>Created message that was submitted to log store or null if Debug is disabled</returns>
        /// <param name="args">Values to be supplied to format specifiers in messageText</param>
        public LogMessage Debug(Exception exception, string messageText, params object[] args)
        {
            LogMessage msg = new LogMessage();
            try
            {
                if (IsDebugEnabled == false) return null;

                msg.Severity = MessageLevel.Debug;
                msg.MessageText = TextUtils.StringFormat(messageText, args);
                msg.AddException(exception);
                return Debug(msg);
            }

            catch (Exception ex)
            {
                Log.LastChanceLog(ex);

            }
            return msg;
        }
Пример #8
0
        /// <summary>
        /// Create a log message at the Debug log level. Message is exception.Message
        /// </summary>
        /// <param name="exception">Exception to write to Debug log</param>
        /// <param name="messageNumber">Numerical index associated with this message</param>
        /// <returns>Created message that was submitted to log store or null if Debug is disabled</returns>
        public LogMessage Debug(Exception exception, string messageNumber)
        {
            LogMessage msg = new LogMessage();
            try
            {
                if (IsDebugEnabled == false) return null;


                msg.Severity = MessageLevel.Debug;
                msg.MessageText = exception.Message;
                msg.AddException(exception);
                msg.MessageCode = messageNumber;
                return Debug(msg);
            }

            catch (Exception ex)
            {
                Log.LastChanceLog(ex);

            }
            return msg;
        }
Пример #9
0
        /// <summary>
        /// Create a log message at the Critical log level. Message is exception.Message
        /// </summary>
        /// <param name="exception">Exception to write to Critical log</param>
        /// <returns>Created message that was submitted to log store</returns>
        public LogMessage Critical(Exception exception)
        {
            LogMessage msg = new LogMessage();
            try
            {
                if (IsCriticalEnabled == false) return null;


                msg.RuntimeContext = new RuntimeContext(RuntimeContextOptions.HttpRequestContext | RuntimeContextOptions.MachineContext);
                msg.Severity = MessageLevel.Critical;
                msg.MessageText = exception.Message;
                msg.AddException(exception);
                if (OnLogCriticalEventHandler != null) OnLogCriticalEventHandler(msg);
            }

            catch (Exception ex)
            {
                Log.LastChanceLog(ex);

            }
            return msg;
        }