예제 #1
0
        public override void Log(ExceptionLoggerContext context)
        {
            var ex = context.Exception;

            string strLogText = "";

            strLogText += Environment.NewLine + "Message ---\n{0}" + ex.Message;
            strLogText += Environment.NewLine + "StackTrace ---\n{0}" + ex.StackTrace;
            strLogText += Environment.NewLine + "TargetSite ---\n{0}" + ex.TargetSite;

            if (ex.InnerException != null)
            {
                strLogText += Environment.NewLine + "Inner Exception is {0}" + ex.InnerException;//error prone
            }
            if (ex.HelpLink != null)
            {
                strLogText += Environment.NewLine + "HelpLink ---\n{0}" + ex.HelpLink;//error prone
            }

            var requestedURi  = (string)context.Request.RequestUri.AbsoluteUri;
            var requestMethod = context.Request.Method.ToString();
            var timeUtc       = DateTime.Now;

            LoggingCRN sqlErrorLogging = new LoggingCRN();
            ApiErrorCE apiError        = new ApiErrorCE()
            {
                Message       = strLogText,
                RequestUri    = requestedURi,
                RequestMethod = requestMethod,
                TimeUtc       = DateTime.Now
            };

            sqlErrorLogging.InsertErrorLog(apiError);
        }
예제 #2
0
 public void InsertErrorLog(ApiErrorCE apiError)
 {
     try
     {
         new LoggingCAD().InsertErrorLog(apiError);
     }
     catch
     {
         throw;
     }
 }
예제 #3
0
        public void InsertErrorLog(ApiErrorCE apiError)
        {
            try
            {
                DbCommand cmd = base.CrearComandoSP();
                cmd.CommandText = "ApiError_Insertar";

                cmd.Parameters.Add(new SqlParameter("@RequestUri", apiError.RequestUri));
                cmd.Parameters.Add(new SqlParameter("@Message", apiError.Message));
                cmd.Parameters.Add(new SqlParameter("@RequestMethod", apiError.RequestMethod));
                cmd.CommandTimeout = 120;
                base.EjecutarComando(cmd);
            }
            catch
            {
                throw;
            }
        }