Beispiel #1
0
        public static void LogToElmah(this Exception ex)
        {
            // recursively log AggregateExceptions
            if (ex is AggregateException)
            {
                AggregateException aggregate = (AggregateException)ex;

                foreach (var e in aggregate.InnerExceptions)
                {
                    if (e != null)
                    {
                        e.LogToElmah();
                    }
                }
            }
            else
            {
                if (HttpContext.Current != null)
                {
                    ErrorSignal.FromCurrentContext().Raise(ex);
                }
                else
                {
                    if (httpApplication == null)
                    {
                        InitNoContext();
                    }
                    ErrorSignal.Get(httpApplication).Raise(ex);
                }
            }
        }
Beispiel #2
0
 public static void LogToElmah(this Exception ex)
 {
     if (HttpContext.Current != null)
     {
         ErrorSignal.FromCurrentContext().Raise(ex);
     }
     else
     {
         if (httpApplication == null)
         {
             InitNoContext();
         }
         ErrorSignal.Get(httpApplication).Raise(ex);
     }
 }
        protected override void OnInit(HttpApplication application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            var config = GetConfig();

            if (config == null)
            {
                return;
            }

            _config = Config.FromDictionary(config);

            application.Error += OnError;
            ErrorSignal.Get(application).Raised += OnErrorSignaled;
        }
Beispiel #4
0
        /// <summary>
        /// Initializes the module and prepares it to handle requests.
        /// </summary>

        protected override void OnInit(HttpApplication application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            var config = (IDictionary)GetConfig();

            if (config == null)
            {
                return;
            }

            #region Settings
            // Extract the settings.
            _facility             = GetSetting(config, "facility");
            _reportAsynchronously = Convert.ToBoolean(GetSetting(config, "async", bool.TrueString));
            var ignored = GetSetting(config, "ignoredProperties", string.Empty);
            if (!string.IsNullOrEmpty(ignored))
            {
                _ignoredProperties = ignored.Split(';');
            }

            if (!Uri.TryCreate(GetSetting(config, "endpoint"), UriKind.RelativeOrAbsolute, out _endpoint))
            {
                throw new ArgumentException("endpoint");
            }

            var addresses = Dns.GetHostAddresses(_endpoint.Host);
            var ip        = addresses
                            .Where(x => x.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                            .FirstOrDefault();

            _ipEndoint = new IPEndPoint(ip, _endpoint.Port);
            #endregion


            application.Error += OnError;
            ErrorSignal.Get(application).Raised += OnErrorSignaled;
        }
Beispiel #5
0
        private static bool RaiseErrorSignal(Exception e)
        {
            var context = HttpContext.Current;

            if (context == null)
            {
                return(false);
            }
            var application = HttpContext.Current.ApplicationInstance;

            if (application == null)
            {
                return(false);
            }
            var signal = ErrorSignal.Get(application);

            if (signal == null)
            {
                return(false);
            }
            signal.Raise(e, context);
            return(true);
        }
        public static void LogToElmah(this Exception ex)
        {
            InitNoContext();

            ErrorSignal.Get(_httpApplication).Raise(ex);
        }
        public void FatalFormat(string format, params object[] args)
        {
            ErrorSignal.Get(application).Raise(new System.ApplicationException(string.Format(format, args)));

            log.FatalFormat(format, args);
        }
        public void Fatal(object message)
        {
            ErrorSignal.Get(application).Raise(new System.ApplicationException(message.ToString()));

            log.Fatal(message);
        }
        public void Fatal(object message, Exception exception)
        {
            ErrorSignal.Get(application).Raise(exception);

            log.Fatal(message, exception);
        }
 /// <summary>
 /// Initializes the module and prepares it to handle requests.
 /// </summary>
 protected override void OnInit(HttpApplication application)
 {
     application.AssertNotNull("application");
     application.Error += new EventHandler(OnError);
     ErrorSignal.Get(application).Raised += new ErrorSignalEventHandler(OnErrorSignaled);
 }