A Glimpse plugin for NHibernate
July 30, 2011This past week I posted over on the Headspring blog how you can create a Glimpse plugin that will log all of the SQL generated by NHibernate. It’s downright easy to create a plugin for Glimpse, and logging SQL from NHibernate has always been available out of the box with Log4Net. All I really did was combine the two.

At the end of this post I’ve embedded the full source code, but head on over to the Headspring post for a full tutorial on this NHibernate Glimpse plugin.
http://www.headspring.com/2011/07/creating-a-glimpse-plugin-to-log-sql-generated-by-nhibernate
One thing that I didn’t mention is that you don’t even have to create a custom plugin to show NHibernate’s generated SQL. You can instead use a Log4Net trace appender and have the SQL statements automagically listed on Glimpse’s Trace tab. One benefit here is the tracing tab will include the time it took to execute, a decent measure of how your queries are performing. The drawback, if any, is the SQL will be mixed in with any other tracing information and you lose the ability to show the number of queries, like my plugin does. Check out Mikael Koskinen’s post if you want to see the Nhibernate-Glimpse-Tracing in action.
Glimpse NHibernate plugin source code
Tags: Glimpse, NHibernate, sql, logging
Categories: ASP.NET MVC, ASP.NET, Database

View Comments & Reactions >>