A Glimpse plugin for NHibernate

July 30, 2011

This 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.

Glimpse Nhibernate Plugin

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



About Kurt

I'm a senior consultant at Headspring in Austin, TX. My passion is creating web-based applications that are well crafted and solve real problems for real people. Want to know more? Check out my about page.

. @LipGlosserie setting up for Renegade Austin craft fair http://t.co/7X4WBVQb 15 hours ago