Currently I have some event listeners setup to log all insert/update/delete actions that happen. I just go through the list of properties and build a string to insert into an audit table.
What I’d really like to do is get the raw SQL query that NHibernate generates. Just like what NHProf shows.
How would I do this?
Put
<property name="show_sql">true</property>in your config file to make it output the SQL to the console.You can also put
<property name="format_sql">true</property>if you want it PrettyPrinted.Alternatively, you can configure log4net (logger is “NHibernate.SQL”, IIRC) and send it anywhere you want.