Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable NHibernate logging

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?

like image 419
ripper234 Avatar asked Sep 23 '09 18:09

ripper234


Video Answer


2 Answers

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> 
like image 173
kgiannakakis Avatar answered Oct 09 '22 20:10

kgiannakakis


return Fluently.Configure()             .Database(MsSqlConfiguration.MsSql2005.ConnectionString(                 c => c.FromConnectionStringWithKey("MyDB")).ShowSql()) 

Removing the .ShowSql() worked for me

like image 41
jenson-button-event Avatar answered Oct 09 '22 21:10

jenson-button-event