Logging NHibernate SQL queries

Posted by GuestMVCAsync on Stack Overflow See other posts from Stack Overflow or by GuestMVCAsync
Published on 2010-02-04T10:24:16Z Indexed on 2010/03/31 22:33 UTC
Read the original article Hit count: 221

Filed under:
|
|

Is there a way to access the full SQL query, including the values, inside my code?

I am able to log SQL queries using log4net:

<logger name="NHibernate.SQL" additivity="false">
    <level value="ALL"/>
    <appender-ref ref="NHibernateSQLFileLog"/>
</logger>

However, I would like to find a way to log SQL queries from the code also. This way I will log the specific SQL query that causes an exception in my try/catch statement.

Right now I have to data-mine the SQLFileLog to find the query that caused the exception when an exception occurs and it is not efficient.

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about .NET