我怎样才能有效地支持实体框架的SQL登录的生产? [英] How can I efficiently support Entity Framework SQL logging in production?

查看:208
本文介绍了我怎样才能有效地支持实体框架的SQL登录的生产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我们正在使用实体框架4.0。当我们遇到一个问题,在生产中,我们希望能够暂时使所有的SQL语句的记录。我们没有生产的SQL Server运行SQL事件探查器上有足够的权限。


We're using Entity Framework 4.0. When we encounter a problem in production, we'd like to be able to temporarily enable logging of all SQL statements. We don't have enough permissions on the production SQL Server to run SQL Profiler.

是否有一个良好的日志选项(A)可通过配置文件设置来开启和关闭,以及(b)不添加时,它关闭?显著的开销

Is there a good logging option that (a) can be turned on and off via a config file setting, and (b) doesn't add significant overhead when it's turned off?

我读过有关跟踪和高速缓存提供包装器的实体框架。这听起来不错...但它的样品code和不正式支持。所以我不知道这是否是适当进行生产。我也不知道,如果包装会增加太多的开销,即使日志记录是关闭的。有没有人有很好的经验,这些包装?

I've read about the Tracing and Caching Provider Wrappers for Entity Framework. This sounds good... but it's sample code and isn't officially supported. So I'm not sure if it would be appropriate for production. I also don't know if the wrapper would add too much overhead even when logging is turned off. Has anyone had good experiences with these wrappers?


感谢您的帮助,
理查德


Thanks for your help,
Richard

推荐答案

在code样品已经发表在的NuGet包。它已经略作​​修改,以配合到内置的.NET跟踪系统(使用 TraceSource ,而不是仅仅文件/控制台日志记录)。

The code sample has been released in a NuGet package. It's been slightly modified to tie into the built-in .NET tracing system (using a TraceSource instead of just file/console logging).

我已经用它的一对夫妇不同的项目,我发现它有帮助。它可以允许/禁止从App.config中/ web.config中,就像任何其他 TraceSource

I've used it on a couple of different projects, and I've found it helpful. It can be enabled/disabled from app.config/web.config just like any other TraceSource.

我还没有任何性能问题,但我只用它在单用户的情况。

I haven't had any performance issues, but I'm only using it in single-user scenarios.

这篇关于我怎样才能有效地支持实体框架的SQL登录的生产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆