优化日志记录

This commit is contained in:
不做码农 2022-03-04 21:00:21 +08:00
parent af07ffc5d1
commit 7bbb076c0e
2 changed files with 7 additions and 2 deletions

View File

@ -76,7 +76,7 @@ namespace ZR.Admin.WebApi.Filters
Data = url
})
{
ContentType = "text/json",
ContentType = "application/json",
};
context.Result = result;
}

View File

@ -1,10 +1,12 @@
using Infrastructure;
using Infrastructure.Attribute;
using Infrastructure.Model;
using IPTools.Core;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Newtonsoft.Json;
using NLog;
using System;
using System.IO;
@ -41,11 +43,14 @@ namespace ZR.Admin.WebApi.Filters
// 获取当前的用户
string userName = context.HttpContext.GetName();
string jsonResult = string.Empty;
if (context.Result is ContentResult result && result.ContentType == "application/json")
{
jsonResult = result.Content.Replace("\r\n", "").Trim();
}
if (context.Result is JsonResult result2)
{
jsonResult = result2.Value?.ToString();
}
//获取当前执行方法的类名
//string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
//获取当前成员的名称