sql日志打印输出配置

This commit is contained in:
陈淳
2022-10-18 09:01:16 +08:00
parent 9d365dbf1e
commit dab4a092d9
20 changed files with 100 additions and 66 deletions

View File

@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
@@ -95,10 +96,9 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
};
db.Aop.OnLogExecuting = (s, p) =>
{
//暂时先关闭sql打印
if (false)
if (GobalModel.SqlLogEnable)
{
var _logger = ServiceLocator.Instance.GetService<ILogger<SqlSugarClient>>();
var _logger = ServiceLocator.Instance?.GetRequiredService<ILogger<SqlSugarClient>>();
StringBuilder sb = new StringBuilder();
sb.Append("执行SQL:" + s.ToString());
@@ -106,8 +106,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
{
sb.Append($"\r\n参数:{i.ParameterName},参数值:{i.Value}");
}
_logger.LogInformation(sb.ToString());
_logger?.LogInformation(sb.ToString());
}

View File

@@ -31,6 +31,10 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
//为 Swagger JSON and UI设置xml文档注释路径
//获取应用程序所在目录(绝对路径不受工作目录影响建议采用此方法获取路径使用windwos&Linux
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
if (basePath is null)
{
throw new Exception("未找到swagger文件");
}
var apiXmlPath = Path.Combine(basePath, @"Config/SwaggerDoc.xml");//控制器层注释
//var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释