<log4net> <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date - %message%newline"/> </layout> </appender> <logger name="NHibernate.SQL" additivity="false"> <level value="DEBUG" /> <appender-ref ref="ConsoleAppender" /> </logger> </log4net>
Thursday, May 08, 2008
Logging the SQL generated by NHibernate
Having used Hibernate for many years but relatively new to NHibernate, I though logging SQL executed by NHibernate would be a simple log4net configuration task, but only to find out it is not as straightforward as I thought. The problem is mainly due to a specious solution on Internet here (Update: Dave correct the post, Thanks!) and here. The correct logger to use is NHibernate.SQL, NOT NHibernate.Loader.Loader. And you need DEBUG level instead of INFO. What's confusing was that the NHibernate.Loader.Loader does log all the SELECT statements but not for UPDATE statement. The XML section below works for me.
2 comments:
Thanks, man. It is exactly what I needed
So where can the files be found?
So many posts on this subject, none specify where the logs can be found.
Post a Comment