<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
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.
Posted by Kenneth Xu at 5/08/2008 05:03:00 PM