我在我的服务堆栈Web服务中有MVC分析器,并且我看到请求被记录到Nlog。Ormlite未使用ServiceStack MVC分析器进行分析
但是,当我试图剖析我的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 https://github.com/ServiceStack/ServiceStack?因为'DependencyResolver.SetResolver'是一个ASP.NET MVC的东西,并且ASP.NET'System.Web.HttpApplication'上的'Application_BeginRequest'和'Application_EndRequest'事件... – nemesv
是的,从我记得服务栈可以暴露web在MVC中托管的服务。我从https://github.com/ServiceStack/ServiceStack/wiki/Built-in-profiling复制了应用程序beginRequest和endRequest –