Merge branch 'master' of https://gitee.com/izory/ZrAdminNetCore
This commit is contained in:
commit
a47821fb69
@ -28,7 +28,7 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
{
|
||||
string connStr = Configuration.GetConnectionString(OptionsSetting.ConnAdmin);
|
||||
string connStrBus = Configuration.GetConnectionString(OptionsSetting.ConnBus);
|
||||
string dbKey = Configuration[OptionsSetting.DbKey];
|
||||
|
||||
int dbType = Convert.ToInt32(Configuration[OptionsSetting.ConnDbType]);
|
||||
int dbType_bus = Convert.ToInt32(Configuration[OptionsSetting.ConnBusDbType]);
|
||||
|
||||
@ -45,8 +45,10 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
IsAutoCloseConnection = true
|
||||
}
|
||||
});
|
||||
//每次Sql执行前事件
|
||||
DbScoped.SugarScope.GetConnection(0).Aop.OnLogExecuting = (sql, pars) =>
|
||||
SugarIocServices.ConfigurationSugar(db =>
|
||||
{
|
||||
#region db0
|
||||
db.GetConnection(0).Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
var param = DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value));
|
||||
|
||||
@ -54,28 +56,33 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
|
||||
logger.Info($"{sql},{param}");
|
||||
};
|
||||
//出错打印日志
|
||||
DbScoped.SugarScope.GetConnection(0).Aop.OnError = (e) =>
|
||||
|
||||
db.GetConnection(0).Aop.OnError = (e) =>
|
||||
{
|
||||
logger.Error(e, $"执行SQL出错:{e.Message}");
|
||||
};
|
||||
//SQL执行完
|
||||
DbScoped.SugarScope.GetConnection(0).Aop.OnLogExecuted = (sql, pars) =>
|
||||
db.GetConnection(0).Aop.OnLogExecuted = (sql, pars) =>
|
||||
{
|
||||
//执行完了可以输出SQL执行时间 (OnLogExecutedDelegate)
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region db1
|
||||
//Db1
|
||||
DbScoped.SugarScope.GetConnection(1).Aop.OnLogExecuting = (sql, pars) =>
|
||||
db.GetConnection(1).Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
var param = DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value));
|
||||
|
||||
logger.Info($"Sql语句:{sql}, {param}");
|
||||
};
|
||||
//Db1错误日志
|
||||
DbScoped.SugarScope.GetConnection(1).Aop.OnError = (e) =>
|
||||
db.GetConnection(1).Aop.OnError = (e) =>
|
||||
{
|
||||
logger.Error($"执行Sql语句失败:{e.Sql},原因:{e.Message}");
|
||||
};
|
||||
#endregion
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -47,6 +47,9 @@
|
||||
<target name="console" xsi:type="ColoredConsole"
|
||||
layout="${date:format=MM-dd HH\:mm\:ss} | ${uppercase:${level}} | ${logger} | ${aspnet-request-iP} | ${aspnet-request-url} | ${message}"/>
|
||||
|
||||
<target name="consoleSql" xsi:type="ColoredConsole"
|
||||
layout="${date:format=MM-dd HH\:mm\:ss} | ${aspnet-request-url} ${newline} ${message}"/>
|
||||
|
||||
<!--写入黑洞-->
|
||||
<target name="blackhole" xsi:type="Null" />
|
||||
</targets>
|
||||
@ -59,6 +62,7 @@
|
||||
<!--<logger name="System.*" writeTo="blackhole" final="true" />-->
|
||||
<!-- Quartz -->
|
||||
<logger name="Quartz*" minlevel="Trace" maxlevel="Info" final="true" />
|
||||
<logger name="ZR.Admin.WebApi.Extensions.DbExtension" final="true" writeTo="consoleSql"/>
|
||||
<logger name="*" minLevel="Debug" writeTo="console"/>
|
||||
<logger name="ZR.Admin.WebApi.Extensions.DbExtension" final="true" writeTo="sqlfile"/>
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ module.exports = {
|
||||
/**
|
||||
* 框架版本号
|
||||
*/
|
||||
version: '3.7.7',
|
||||
version: '3.7.8',
|
||||
title: 'ZrAdmin.NET-后台管理',
|
||||
/**
|
||||
* 主题颜色
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user