1

我正在尝试将 ServiceStack 的 MiniProfiler 结果记录到 SQL Server,如下所示:http: //geekswithblogs.net/mknapp/archive/2012/02/22/query-performance-logging-with-miniprofiler.aspx

注意:上面没有使用 ServiceStack 的 MiniProfiler,但我在这部分没有找到特定的 ServiceStack 文档。

我的问题是使用 ServiceStack 的 MiniProfiler 我无法解析“ SqlServerStorage ”,例如:

Profiler.Settings.Storage = new SqlServerStorage(connStr);

我有 MiniProfiler 在 ServiceStack(3.9.55.0 / IIS7 托管)中使用 OrmLite 的 ProfiledDbConnection 工作,默认的页面/实时结果(通过 HttpRuntimeCacheStorage)一切都很好。

你能看出我在下面做的事情有什么问题吗,或者你能提供一个简单的例子来说明如何使用 ServiceStack 运行它吗?

protected void Application_BeginRequest(object sender, EventArgs e)
{
    if (Request.IsLocal)
    {
        var connStr = _connStr;

        // *** my problem is that SqlServerStorage is not resolving ***
        Profiler.Settings.Storage = new SqlServerStorage(connStr);

        // *** whereas HttpRuntimeCacheStorage is resolved and works fine ***
        //Profiler.Settings.Storage = new HttpRuntimeCacheStorage(new TimeSpan(0,0,10);

        Profiler.Start();
    }
}

更新: 解决集成日志记录仍然没有运气。如果它有助于以后阅读此内容的任何人,您可以像这样明确记录结果:https ://code.google.com/p/mvc-mini-profiler/issues/detail?id=36

protected void Application_EndRequest()
        {
            MiniProfiler miniProfiler = MiniProfiler.Current;

            MiniProfiler.Stop();

            if (miniProfiler != null)
            {
                Log.Debug(m => m("profiling result id:{0}\nresult:{1}", miniProfiler.Id,miniProfiler.Render()));
            }
        }
4

0 回答 0