问题
I am using Visual Studio 2010 with NHibernate 3.1 and using Fluent NHibernate for mapping. It has been working well, and with the ShowSql enabled it shows all the select queries.
I have gotten to the portion of the program where I am performing some updates, but they don't show. At first I thought the updates weren't getting triggered even though i was using an explicit transaction - but the data was getting changed in the database. So - somehow, the queries are being executed, but not shown in the Output window of Visual Studio.
Any ideas?
Edit It turns out I was mixing two answers together. Log4Net is not needed at all to produce UPDATE statements from NHibernate in the output window.
Setting AdoNetBatchSize(0) in conjunction with ShowSQL DID resolve the problem.
回答1:
May I suggest you give NHibernate Profiler a try. I've been using it for the last year or so and it has proved invaluable. It will show you all the queries in a very useful way. You could just use the 30 day trial to solve your problem.
- Disclaimer: I am in no way affiliated with Hibernating Rhinos or Ayende, just a happy customer.
回答2:
It looks like your logConfig.xml file is missing the configSections section under the configuration tags.
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
</configSections>
Another way is to remove the configuration tags so the log4net tags are at the root of the xml document. For troubleshooting purposes you could put the configuration in MyApp.exe.config or Web.config as in this.
See the log4net documentation for more details.
If you would like to use it to log other parts of your app see this.
来源:https://stackoverflow.com/questions/9050930/nhibernate-not-showing-update-queries-with-showsql-enabled