nhibernateprofilersql-server-profiler

How initial startup for NHibernate Profiler


I have a Wpf application using Nhibernate. I want to see details of sent query to database by NHibernate Profiler. For initial startup, what should I do?


Solution

  • There are multiple ways of integrating nhibernate profiler into your application. One way is to use the custom nhibernate profiler log4net appender. You can find out how to use this way here:

    http://nhprof.com/Learn/Usage/ProfileAppWithConfiguration

    Another way to do this is to include HibernatingRhinos.Profiler.Appender.v4.0.dll into your project and include the following code somewhere at startup (I usually include this in my SessionFactory helper class that initializes my SessionFactory and hands out ISessions):

    //Using statement needed for the statement below
    using HibernatingRhinos.Profiler.Appender.NHibernate;
    
    //Initialize so that we can use NHibernate Profiler (http://nhprof.com/)
    NHibernateProfiler.Initialize();
    

    Also if you want to view nhibernate statistics from within nhibernate profiler you need to include the following in your nhibernate configuration section:

    <property name="generate_statistics">true</property> 
    

    All of this information can be found here: http://nhprof.com/