【发布时间】:2013-02-03 08:05:25
【问题描述】:
我的服务堆栈 Web 服务中有 MVC 分析器,我看到请求被记录到 Nlog。
但是,当我尝试分析我的 PostgreSQL 数据库时,没有生成任何日志。
我的 global.asax.cs 中有:
var dbConnectionFactory = new OrmLiteConnectionFactory(
"Server=127.0.0.1;Port=5432;Database=mydatabase;User
Id=id;Password=password;")
{
ConnectionFilter = x => new
ProfiledDbConnection(x, Profiler.Current)
};
builder.RegisterInstance(dbConnectionFactory).
ExternallyOwned().As<IDbConnectionFactory>();
var autofacContainer = builder.Build();
//set Autofac as default Dependency Resolver for application
DependencyResolver.SetResolver(new
AutofacDependencyResolver(autofacContainer));
和
protected void Application_BeginRequest()
{
if (Request.IsLocal)
{
Profiler.Start();
}
}
protected void Application_EndRequest(object src, EventArgs e)
{
if (Profiler.Current != null)
{
Logger.Debug("profiling result id:{0}\nresult:{1}", Profiler.Current.Id,Profiler.Current.Render());
}
Profiler.Stop();
}
【问题讨论】:
-
你真的在使用ServiceStack github.com/ServiceStack/ServiceStack吗?因为
DependencyResolver.SetResolver是一个 ASP.NET MVC 事物,而 ASP.NET 上的Application_BeginRequest和Application_EndRequest事件System.Web.HttpApplication... -
是的,据我所知,服务堆栈可以公开托管在 MVC 中的 Web 服务。我从 github.com/ServiceStack/ServiceStack/wiki/Built-in-profiling 复制了 Application beginRequest 和 endRequest
标签: c# servicestack ormlite-servicestack