Exemplo n.º 1
0
        protected void LogException(Exception exc)
        {
            if (exc == null)
            {
                return;
            }
            //ignore 404 HTTP errors
            var httpException = exc as HttpException;

            if (httpException != null && httpException.GetHttpCode() == 404)
            {
            }

            try
            {
                //log

                SysExceptionLog exceptionLogEntry = new SysExceptionLog();
                exceptionLogEntry.ExceptionSource      = exc.Source;
                exceptionLogEntry.ExceptionDescription = exc.Message;
                exceptionLogEntry.ExceptionStackTrace  = exc.StackTrace;
                exceptionLogEntry.ExceptionTargetSite  = exc.TargetSite.ToString();
                exceptionLogEntry.ExceptionType        = "1";
                exceptionLogEntry.ExceptionTypeName    = "Api异常";

                WriteExceptionLog.WriteLogException(exceptionLogEntry);
                // var log = LogManager.GetLogger("api");
                LogHelper.WriteErrorLog(Context.Request.Url.ToString(), Context.Error);
            }
            catch (Exception)
            {
                //don't throw new exception if occurs
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加错误日志
        /// </summary>
        /// <param name="log"></param>
        public void EmitLog(SysExceptionLog log)
        {
            if (log != null)
            {
                log.Enabled       = 1;
                log.DeleteDate    = null;
                log.ExceptionDate = DateTime.Now;
                log.InDate        = DateTime.Now;

                ServiceProvider provider = new ServiceProvider();
                provider.RegisterService <SysExceptionLogService>(true);
                using (var service = provider.GetService <SysExceptionLogService>())
                {
                    LogHelper.WriteInfoLog($"exception info:{JsonHelper.SerializeObject(log)}");
                    service.Add(log);
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 插入记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public long Add(SysExceptionLog model)
 {
     return(this._exceptionTokenRepository.Insert(model));
 }
Exemplo n.º 4
0
        public static void WriteLogException(SysExceptionLog model)
        {
            LoginEmitter service = new LoginEmitter();

            service.EmitLog(model);
        }