From bb8a3598a7cca139e1774baf1cb585ffbde64c3b Mon Sep 17 00:00:00 2001
From: falcon <9504402@qq.com>
Date: Sun, 12 Apr 2020 16:06:23 +0800
Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AElog=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FAuth/Models/ApiErrorResult.cs | 4 +-
FAuth/Models/ApiExceptionFilterAttribute.cs | 6 +--
FAuth/nlog.config | 41 +++++++++++++++++++++
3 files changed, 46 insertions(+), 5 deletions(-)
create mode 100644 FAuth/nlog.config
diff --git a/FAuth/Models/ApiErrorResult.cs b/FAuth/Models/ApiErrorResult.cs
index 2b22a3f..d73740c 100644
--- a/FAuth/Models/ApiErrorResult.cs
+++ b/FAuth/Models/ApiErrorResult.cs
@@ -10,8 +10,8 @@
///
public string Message { get; set; }
///
- /// 客户端存储编号
+ /// 异常编号
///
- public string Storage { get; set; }
+ public string Id { get; set; }
}
}
diff --git a/FAuth/Models/ApiExceptionFilterAttribute.cs b/FAuth/Models/ApiExceptionFilterAttribute.cs
index 5cc3845..e6641f8 100644
--- a/FAuth/Models/ApiExceptionFilterAttribute.cs
+++ b/FAuth/Models/ApiExceptionFilterAttribute.cs
@@ -18,11 +18,11 @@ namespace FAuth.Models
this.Logger = logger;
}
public override void OnException(ExceptionContext context) {
- this.Logger.LogError(context.Exception.ToString());
- var storage = Guid.NewGuid().ToString();
+ var id = Guid.NewGuid().ToString("N");
+ this.Logger.LogError(id + "|" + context.Exception.ToString());
var result = new ApiErrorResult {
Message = context.Exception.Message,
- Storage = storage,
+ Id = id,
};
context.Result = new JsonResult(result) { StatusCode = StatusCodes.Status500InternalServerError };
}
diff --git a/FAuth/nlog.config b/FAuth/nlog.config
new file mode 100644
index 0000000..c101bf6
--- /dev/null
+++ b/FAuth/nlog.config
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file