日志重写
This commit is contained in:
@@ -53,6 +53,12 @@
|
||||
<Reference Include="MySql.Data, Version=8.1.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MySql.Data.8.1.0\lib\net462\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.6.0.2\lib\net46\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.Windows.Forms.6.0.2\lib\net35\NLog.Windows.Forms.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SqlSugar, Version=5.1.4.94, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SqlSugar.5.1.4.94\lib\SqlSugar.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -69,6 +75,7 @@
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.7.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Pipelines, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Pipelines.7.0.0\lib\net462\System.IO.Pipelines.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -99,6 +106,7 @@
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace JinYuan.DAL
|
||||
/// 数据库连接字符串
|
||||
/// </summary>
|
||||
public static string connString = string.Empty;
|
||||
|
||||
private static LoggerHelp _logger = new LoggerHelp();
|
||||
/// <summary>
|
||||
/// 数据库类型
|
||||
/// </summary>
|
||||
@@ -39,7 +39,7 @@ namespace JinYuan.DAL
|
||||
db.Ado.CommandTimeOut = 3000;//设置执行语法超时时间
|
||||
db.Aop.OnLogExecuted = (sql, pars) => //SQL执行完事件
|
||||
{
|
||||
LogHelper.Instance.WriteLog($"执行时间:{db.Ado.SqlExecutionTime.TotalMilliseconds}毫秒 \r\nSQL如下:{sql} \r\n参数:{GetParams(pars)} ", "SQL执行");
|
||||
LoggerHelp.WriteLog($"执行时间:{db.Ado.SqlExecutionTime.TotalMilliseconds}毫秒 \r\nSQL如下:{sql} \r\n参数:{GetParams(pars)} ", "SQL执行");
|
||||
};
|
||||
db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前事件
|
||||
{
|
||||
@@ -47,7 +47,7 @@ namespace JinYuan.DAL
|
||||
};
|
||||
db.Aop.OnError = (exp) =>//执行SQL 错误事件
|
||||
{
|
||||
LogHelper.Instance.WriteError($"SQL错误:{exp.Message}\r\nSQL如下:{exp.Sql}", "SQL执行");
|
||||
LoggerHelp.WriteLog($"SQL错误:{exp.Message}\r\nSQL如下:{exp.Sql}", "SQL执行");
|
||||
throw new Exception(exp.Message);
|
||||
};
|
||||
db.Aop.OnDiffLogEvent = (it) => //可以方便拿到 数据库操作前和操作后的数据变化。
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using JinYuan.DAL;
|
||||
using JinYuan.DAL.Enums;
|
||||
using JinYuan.DAL.Models;
|
||||
using NLog;
|
||||
using Org.BouncyCastle.Asn1;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
@@ -18,6 +19,8 @@ namespace JinYuan.DAL
|
||||
|
||||
public class SQLSugarService : ISugarHepler
|
||||
{
|
||||
|
||||
|
||||
public void SetConnectionStr(string connectionStr, SqlSugar.DbType dbType= SqlSugar.DbType.SqlServer)
|
||||
{
|
||||
SQLSugarHelper.connString = connectionStr;
|
||||
@@ -856,7 +859,7 @@ namespace JinYuan.DAL
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
LoggerHelp.WriteInfo("aaa");
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
<package id="K4os.Hash.xxHash" version="1.0.8" targetFramework="net462" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
|
||||
<package id="MySql.Data" version="8.1.0" targetFramework="net472" />
|
||||
<package id="NLog" version="6.0.2" targetFramework="net472" />
|
||||
<package id="NLog.Windows.Forms" version="6.0.2" targetFramework="net472" />
|
||||
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net462" />
|
||||
<package id="SqlSugar" version="5.1.4.94" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
|
||||
|
||||
Reference in New Issue
Block a user