Daily Usage Issues

Can't get log output from NHibernate with NCrunch.

Started by GreenMoose on 8,887 views

[1.41.0.50b]/VS2010/NUnit

I have a test using NHibernate that outputs a bunch of NHibernate-specific logging (sql statements etc.) when I run it via ReSharper's test runner or NUnit's GUI runner. Example:

log4net: XmlHierarchyConfigurator: Configuration update mode [Merge].
...
15:53:18.221 [TestRunnerThread] INFO  Environment (null) - NHibernate 3.1.0.4000 (3.1.0.4000)
...
15:53:26.311 [TestRunnerThread] DEBUG MyTest (null) - TEST!


However when I run it via NCrunch the output is only displaying the log4net debug info and the my own log entries, none of the log entries for NHibernate. Example:
log4net: XmlHierarchyConfigurator: Configuration update mode [Merge].
...
15:54:49.830 [11] DEBUG MyTest (null) - TEST!



Is this a known issue? (Not particular for NHibernate but I guess the same logging "problem" exist with other 3rd party libraries?).

Thanks.
Hrm, when setting "Copy referenced assemblies to workspace" to True it display log output from NHibernate (as expected). Should this be necessary?
Hi, thanks for posting!

My suspicion is that there is an implicit reference between the log4net code and the NHibernate logger. Most likely log4net is searching for additional loggers within your build output directory by scanning through adjacent assemblies that export a particular interface, or it's referencing the NHibernate logger DLL using a configuration file. I can't confirm 100% that this is the case without running through the log4net/NHibernate source code myself, but it would probably make sense.

Because NCrunch isolates components in their own workspaces, the above code wouldn't find the NHibernate logger as the binary wouldn't be stored in the right place. Turning on the 'Copy referenced assemblies to workspace' emulates normal behaviour and thus allows the code to work.

You'll need to make a decision as to whether or not you wish to continue using the 'Copy referenced assemblies to workspace' setting. If your solution is large, this setting can result in greatly elevated build times and is generally best avoided. You might want to look at other ways of registering the NHibernate logger with with log4net - from memory, there are many different ways of doing this. If you can do it using SetUp code within your tests, this may allow you to cleanly work around the problem.


Cheers,

Remco
For the record, it was sufficient explicitly copying NHibernate.dll and log4net.dll, which has a lot less impact on build time than the "Copy referenced assemblies to workspace" option.
Good to know! Did you manage this using a custom build step? I'm wondering if it's an option worth suggesting to people as a more performance-friendly alternative to the 'Copy referenced assemblies to workspace' setting.
I used NCrunch's config option "Additional files to include".
This post has been deleted.

Post a reply

Log in to reply.