Reputation: 229988
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?
Upvotes: 54
Views: 20715
Reputation: 104168
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>
Upvotes: 88
Reputation: 2634
The NHibernate logs don't help me much... I like these settings better:
<logger name="NHibernate">
<level value="OFF" />
</logger>
<logger name="NHibernate.SQL">
<level value="OFF" />
</logger>
Upvotes: 4
Reputation: 21
For me it was the NUnit problem. The extra logging was happening when running the tests in TeamCity which must have been using a different version of nunit
Upvotes: 2
Reputation: 229988
The problem was somewhere in "my code". We build the NHibernate configuration manually (setting the show_sql flag to true).
Upvotes: 6
Reputation: 18941
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(
c => c.FromConnectionStringWithKey("MyDB")).ShowSql())
Removing the .ShowSql()
worked for me
Upvotes: 15
Reputation: 3493
Are you using NUnit 2.4.6? I read this blog post yesterday which says that this version of NUnit sets log4net to use DEBUG level logging, effecting NHibernate as well.
if it's not NUnit and it's not you, I would check if it's some other 3rd party library that you're using.
EDIT
On second thought, I don't think that the output has something to do with log4net. the format looks more like the "show_sql" controlled output. I would check two things: 1. If the correct (the one with the show_sql=false) hibernate.config is copied to your execution directory. 2. If the show_sql configuration property is not overridden manually in your code.
Upvotes: 0
Reputation: 12401
Do you want to disable the logging at the NHibernate level or the Log4Net level?
I'm doing the former by setting "show_sql" variable to false. I'm doing this programmatically in C# right now, but I assume this would be easy to put in an XML configuration file as well.
Upvotes: 2