tags:

views:

76

answers:

3

Hi. Is there a way to monitor the round-trips to the database in an NHibernate application? I need just a log to see when NHibernate connects to database.

+3  A: 

You can 'monitor' via logging using NH's log4net. Some useful info here.

That will be monitor from the application side.

Have you tried monitoring from the DB serverside? E.g. enable logging at the say mySql.

o.k.w
+6  A: 

Have a look at NHibernate Profiler (NHProf) if you don't mind a commercial product. Some of its features are:

  • Visual insight into the interaction between your database and application code.
  • Analysis and detection of common pitfalls when using NHibernate.
  • Analysis is delivered via perfectly styled SQL and linkable code execution.
  • Supports NHibernate (.NET) and Hibernate (Java).
M4N
+2  A: 

In addition to NHProf and log4net, there is also a "show_sql" config entry that will dump the SQL to the console in a console app.

Your database vendor should also have tools for monitoring the SQL that is being run against it.

Michael Maddox