【问题标题】:How can I turn off Entity Framework 6.1 logging?如何关闭 Entity Framework 6.1 日志记录?
【发布时间】:2014-03-28 10:12:06
【问题描述】:

文档说明我可以像这样打开日志记录:

using (var context = new BlogContext())
{
    context.Database.Log = Console.Write;                       // like this
    context.Database.Log = logInfo => Debug.WriteLine(logInfo); // or like this

    // Your code here...

    // How can I turn off logging here ?
}

我没有看到有关如何关闭它的任何信息。谁能告诉我怎么做?

【问题讨论】:

  • 如果您在分配给它之前检查context.Database.Log,您会看到什么?您应该能够使用相同的值来重置它。 (我不知道那个值是什么。它可能是null,也可能是某种忽略其参数的方法。)

标签: asp.net asp.net-mvc entity-framework entity-framework-6


【解决方案1】:

只要打电话

context.Database.Log = null;

那么你已经关闭了日志记录

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-22
    • 1970-01-01
    • 2012-03-02
    • 2012-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多