我怎样才能让 Miniprofiler 只调用可能记录配置文件消息的方法

How can I have Miniprofiler just call may log method for the profile messages

我正在构建 windows 服务。

我正在尝试使用 miniprofiler,拦截 ado.net 调用并将消息传递到我的应用程序的日志系统。

miniprofiler 需要做的就是调用静态方法 Log(string text)。

我经历了以下 post 并学会了如何拦截 ado.net 电话:

Using MiniProfiler for direct ADO.net calls

看来唯一的未解之谜就是让miniprofile调用我的log方法。我怎样才能做到这一点?

我浏览了网站 http://miniprofiler.com/,但文档很少。

简而言之:这不是 MiniProfiler 的设计目的,因为那不是分析。

但是,您很幸运在这里实现了 MiniProfiler。您可以实施 IDbProfiler yourself that just calls the logger. There are only a handful of methods. Here's MiniProfiler's implementation.

如果您的实现只是调用您的日志记录方法,您可以重新使用为 MiniProfiler 构建的所有 ADO.NET 位,如下所示:

IDbProfiler logger = new YourLogger();
var conn = new SqlServerConnection(myConnectionString);
var profiledConn = new ProfiledDbConnection(cnn, logger);
// ...do stuff with profiledConn