本文转自:https://stackoverflow.com/questions/44202478/lost-parameter-value-during-sql-trace-in-ef-core

问:

I have implemented an approach for tracing SQL queries from EF Core according to this article: https://docs.microsoft.com/en-us/ef/core/miscellaneous/logging.

And have problems with tracing query parameteres.

When I recive Log event in all values of DbParameterLogData

I see only the question mark instead of the actual values wich I passed to the query. Example image VS 2015. Thank you!

答:

This is the default behavior of EF Core (filling up the DbParameterLogData.Value property with "?").

In order to get the real parameter values, you need to enable sensitive data logging by using DbContextOptionsBuilder.EnableSensitiveDataLogging method:

Enables application data to be included in exception messages, logging, etc. This can include the values assigned to properties of your entity instances, parameter values for commands being sent to the database, and other such data. You should only enable this flag if you have the appropriate security measures in place based on the sensitivity of this data.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.EnableSensitiveDataLogging();
// ...
}

 

Sometimes this results in a MissingMethodException.

In which case, you should call it in ConfigureServices():

services.AddDbContext<MyDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("Defa‌​ultConnection")).Ena‌​bleSensitiveDataLogg‌​ing()) – yfisaqt Jul 6 at 21:10

[转]Lost parameter value during SQL trace in EF Core DbParameter 为 问号 ?的更多相关文章

  1. EF Core 2.1 Raw SQL Queries (转自MSDN)

    Entity Framework Core allows you to drop down to raw SQL queries when working with a relational data ...

  2. Oracle sql trace

    一.SQL_TRACE说明 1.1.在全局启用 在参数文件(pfile/spfile)中指定:sql_trace =true 1.2.在当前session级设置 启用当前session的跟踪: alt ...

  3. SQL Server 扩展事件(Extented Events)从入门到进阶(1)——从SQL Trace到Extented Events

    由于工作需要,决定深入研究SQL Server的扩展事件(Extended Events/xEvents),经过资料搜索,发现国外大牛的系列文章,作为“学习”阶段,我先翻译这系列文章,后续在工作中的心 ...

  4. SQL TRACE

    1.SQL TRACE说明: 参数类型 布尔型 缺省值 false 参数类别 动态 取值范围 True|false 2.类型 1)sql trace参数:alter system改变对全局进程影响,如 ...

  5. PLSQL_性能优化效能跟踪工具SQL Trace分析(案例)

    2014-06-25 Created By BaoXinjian

  6. SAP 使用SQL Trace(ST05)

    SAP 使用SQL Trace(ST05) SAP R/3 提供标准ABAP SQL 跟踪工具.使用T-Code:ST05 可以进入追踪设定画面:          在Trace Modes 区域中选 ...

  7. Oracle 11g R2性能优化 SQL TRACE

    作为Oracle官方自带的一种基本性能诊断工具,SQL Trace可以用来评估当前正在运行的SQL语句的效率,同时为该语句生成统计信息等,并保存这些信息到指定路径下的跟踪文件(trace)当中.SQL ...

  8. Oracle核心技术之 SQL TRACE

    1.SQL TRACE说明: 参数类型 布尔型 缺省值 false 参数类别 动态 取值范围 True|false 2.类型 1)sql trace参数:alter system改变对全局进程影响,如 ...

  9. SQL Server Extended Events 进阶 1:从SQL Trace 到Extended Events

    http://www.sqlservercentral.com/articles/Stairway+Series/134869/ SQL server 2008 中引入了Extended Events ...

随机推荐

  1. Chrome自定义缩放百分比

    我想要设置Chrome页面缩放为120%,但是Chrome只提供110% 125%,根本没有让我舒心的缩放比例. 强迫症发作,谷歌了半天没有一个很好的解决方案. 虽然也有不少第三方扩展可以自定义缩放比 ...

  2. js实现回车登陆

    2018-11-15 $(document).keydown(function (event) { if (event.keyCode == 13) { $("#LoginBtn" ...

  3. 基于Quartz.net的远程任务管理系统 一

    在上一篇绪中,已经介绍了整个项目的情况下了,接下来就是开始一步步做起来了. 首先:先整个我们的Job任务表,以及Job执行日志表.SQL如下: drop table if exists job_inf ...

  4. 手写数字识别---demo

    数据准备 课程中获取数据的方法是从库中直接load_data from keras.datasets import mnist (x_train, y_train), (x_test, y_test) ...

  5. 1000. Minimum Cost to Merge Stones

    There are N piles of stones arranged in a row.  The i-th pile has stones[i] stones. A move consists ...

  6. MySQL(动态执行SQL)

    day61 防sql注入 delimiter \\ CREATE PROCEDURE p4 ( ), in arg int ) BEGIN set @xo = arg; PREPARE xxx FRO ...

  7. Apache Log4j配置说明

    1.Log4j简介 Log4j是Apache的一个开源项目,它允许开发者以任意间隔输出日志信息.Log4j主要由三大类组件构成: 1)Logger-负责输出日志信息,并能够对日志信息进行分类筛选,即决 ...

  8. Flask从入门到精通之在视图函数中处理表单

    在新版hello.py 中,视图函数index() 不仅要渲染表单,还要接收表单中的数据.更新后的index() 视图函数如下: @app.route('/') def index(): name = ...

  9. linux文件的硬连接和软连接

    建立软连接:ln -s 原路径 目标路径 原理示意图: 特点: 1.     相当于win中的快捷方式 2.     删除链接文件,源文件不受影响 3.     删除源文件,链接文件失效 4.     ...

  10. D04——C语言基础学PYTHON

    C语言基础学习PYTHON——基础学习D04         20180810内容纲要: 1 内置函数 2 装饰器 3 生成器 4 迭代器 5 软件目录结构规范 6 小结 1 内置函数 内置函数方法详 ...