From ce76c59aa667c1974037d1e5923a07f7cb951dd0 Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Wed, 31 Oct 2018 17:40:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97=E5=86=99=E5=85=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.DataAccess.MongoDB/Exceptions.cs | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Bootstrap.DataAccess.MongoDB/Exceptions.cs b/Bootstrap.DataAccess.MongoDB/Exceptions.cs index 6cfbf64f..545713ee 100644 --- a/Bootstrap.DataAccess.MongoDB/Exceptions.cs +++ b/Bootstrap.DataAccess.MongoDB/Exceptions.cs @@ -1,6 +1,7 @@ using MongoDB.Driver; using System; using System.Collections.Generic; +using System.Collections.Specialized; namespace Bootstrap.DataAccess.MongoDB { @@ -16,6 +17,7 @@ namespace Bootstrap.DataAccess.MongoDB MongoDbAccessManager.Exceptions.DeleteMany(ex => ex.LogTime < DateTime.Now.AddDays(-7)); }); } + /// /// /// @@ -24,5 +26,28 @@ namespace Bootstrap.DataAccess.MongoDB { return MongoDbAccessManager.Exceptions.Find(ex => ex.LogTime >= DateTime.Now.AddDays(-7)).ToList(); } + + /// + /// + /// + /// + /// + /// + public override bool Log(Exception ex, NameValueCollection additionalInfo) + { + var excep = new Exceptions(); + excep.Id = null; + excep.AppDomainName = AppDomain.CurrentDomain.FriendlyName; + excep.ErrorPage = additionalInfo?["ErrorPage"]; + excep.ExceptionType = ex.GetType().FullName; + excep.LogTime = DateTime.Now; + excep.Message = ex.Message; + excep.StackTrace = ex.StackTrace; + excep.UserId = additionalInfo?["UserId"]; + excep.UserIp = additionalInfo?["UserIp"]; + MongoDbAccessManager.Exceptions.InsertOne(excep); + ClearExceptions(); + return true; + } } }