2
votes

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.

2
type="log4net.Appender.TraceAppender" use this instead if you are wanting to write the visual studio output window.Cole W
Thanks for your feedback. I made this change but I'm still not seeing anything in the output. Is there some part of the configuration I'm missing?Origin
Any chance of seeing the code where you perform the update? Are you definitely wrapping the thing in a transaction? Have you tried forcing a commit? Also, I wasn't trying to sell you NHProfiler, but why don't you use the 30 day trial to solve your problem. It won't cost you anything. You'll know for sure if it's a problem with your logger or your code if you've tried log4net AND NHProf.autonomatt
Have you seen this question on SO? It looks like your problem (with solution).autonomatt
I tried the NH Profiler trial and my code was working fine. NH Profiler shows the update commands. And I know the logger wasn't working - because Log4Net wasn't even showing the select commands (which the ShowSQL was outputting). I had no doubt on the power of NH Profiler, I just didn't want to see what "could be" if I won't be able to use it in the long run. I was hoping to find out how to solve the problem with the core software, and not 3rd party solutions. It really seems like a bug with ShowSQL if it doesn't show updates.Origin

2 Answers

1
votes

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.
0
votes

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.