Disable NHibernate logging

ripper234 picture ripper234 · Sep 23, 2009 · Viewed 19k times · Source

I have an empty app.config file, but I still get NHibernate debug logs

NHibernate: SELECT this_.LogID as LogID71_0_, this_.Level as Level71_0_, this_.Message as Message71_0_, this_.EventTime as EventTime71_0_, this_.Component as ...

I tried adding a log4net configuration with an ERROR log level, but no use. How can I stop these log messages?

The thing I'm puzzled about is why do these appear in the first place if I have an empty app.config to being with. It doesn't make sense to me that I have to configure it not to print these messaages - the default should be off. Could it be my code is setting them on programatically somehow? What should I look for?

Answer

kgiannakakis picture kgiannakakis · Sep 23, 2009

Configure Log4Net for use with NHibernate may be helpful.

You need to have both these loggers:

 <logger name="NHibernate">
   <level value="ERROR" />
 </logger>

 <logger name="NHibernate.SQL">
   <level value="ERROR" />
 </logger>