为了账号安全,请及时绑定邮箱和手机立即绑定

对于记录详细的日志,xxx修改了某个字段,原来值是多少,新值是多少这种日志大家有什么高见

对于记录详细的日志,xxx修改了某个字段,原来值是多少,新值是多少这种日志大家有什么高见

慕的地8271018 2018-08-13 10:14:45
对于记录详细的日志,xxx修改了某个字段,原来值是多少,新值是多少这种日志大家有什么高见
查看完整描述

1 回答

?
收到一只叮咚

TA贡献1821条经验 获得超4个赞

class EfIntercepterLogging : DbCommandInterceptor
{
private readonly Stopwatch _stopwatch = new Stopwatch();
public override void ScalarExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
{
base.ScalarExecuting(command, interceptionContext);
_stopwatch.Restart();
}
public override void ScalarExecuted(System.Data.Common.DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
{
_stopwatch.Stop();
if (interceptionContext.Exception != null)
{
Trace.TraceError("Exception:{1} \r\n --> Error executing command: {0}", command.CommandText, interceptionContext.Exception.ToString());
}
else
{
Trace.TraceInformation("\r\n执行时间:{0} 毫秒\r\n-->ScalarExecuted.Command:{1}\r\n", _stopwatch.ElapsedMilliseconds, command.CommandText);
}
base.ScalarExecuted(command, interceptionContext);
}

一处地方,几句代码搞定。


查看完整回答
反对 回复 2018-08-23
  • 1 回答
  • 0 关注
  • 873 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信