Example #1
0
        protected void Application_Error(object sender, EventArgs e)
        {
            //记录异常日志并抛出异常
            Exception ex = Server.GetLastError().GetBaseException();

            if (ex != null)
            {
                StringBuilder errorMsg = new StringBuilder();
                errorMsg.AppendLine(string.Format("URL:{0}", Request.Url.ToString()));
                errorMsg.AppendLine(string.Format("TargetSite:{0}", ex.TargetSite));
                errorMsg.AppendLine(string.Format("Message:{0}", ex.Message));
                errorMsg.AppendLine(string.Format("StackTrace:{0}", ex.StackTrace));
                errorMsg.AppendLine(string.Format("Server IP:{0},Client IP:{1}", AppEnvironment.LocalIPAddress, JFx.Utils.Utility.GetClientIp()));

                //加入用户相关信息
                log.Error(errorMsg.ToString());
            }
            //加入Metrics
            MetricsManager.MeterMark("Flight.Provider.ExceptionCount", Unit.Custom("个"));
        }