1
votes

I'm currently using NHibernate 3.1 in a ASP.Net application and got it working pretty well (with Fluent). I managed to make it log all generated SQL queries to my output tab while debugging by using the following snippet in Application_Start:

private static DebugTextWriter _writer;

protected virtual void Application_Start(object sender, EventArgs e) { _writer = new DebugTextWriter(); Console.SetOut(_writer);
}

I recently upgraded NHibernate from 2.1 to 3.1 and now my update and delete statements are no longer being output to the to log...

Do you guys have any idea why?

Thanks

2
Do you have a reference to log4net as I believe it is not a requirement in NH 3+ or have .ShowSql() in your cfg codeRippo
Hi, I do not have a reference to log4net and I'm using the show_sql property in my hibernate.cfg.xml file.BredStik

2 Answers

1
votes

I finally found what was causing this behavior. It turns out that the adonet.batch_size entry in the hibernate.cfg.xml file is causing the problem. After removing this property element, the update and delete statements were finally output as expected.

Thanks for your answers and comments.

0
votes

In order to log using log4net, you don't need to define show_sql, you just need to configure the loggers named NHibernate and NHibernate.SQL. Make sure you don't restrict the levels - could it be that you're only logging from level INFO and above, and the messages you're missing are at level DEBUG?

Here is a short tutorial: http://nhforge.org/wikis/howtonh/configure-log4net-for-use-with-nhibernate.aspx