How can I turn off Entity Framework 6.1 logging?

2019-08-05 11:48发布

The documentation states that I can turn on logging like this:

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 ?
}

I don't see any information on how to turn it off. Can someone tell me how I can do this?

1条回答
劳资没心,怎么记你
2楼-- · 2019-08-05 12:31

Just call

context.Database.Log = null;

then you have turned of logging

查看更多
登录 后发表回答