如何关闭Entity Framework 6.1日志记录? [英] How can I turn off Entity Framework 6.1 logging?
本文介绍了如何关闭Entity Framework 6.1日志记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
using(var context = new BlogContext())
{
context.Database.Log = Console.Write; // like this
context.Database.Log = logInfo =>的Debug.WriteLine(LOGINFO); //或像这样
//您的代码在这里...
//如何关闭日志记录?
}
我没有看到有关如何关闭它的信息。有人可以告诉我如何做到这一点吗?
解决方案
只需调用
context.Database.Log = null;
那么你已经转过来记录了
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?
解决方案
Just call
context.Database.Log = null;
then you have turned of logging
这篇关于如何关闭Entity Framework 6.1日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文