Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Can't get log output from NHibernate with NCrunch.
GreenMoose
#1 Posted : Wednesday, October 10, 2012 2:00:23 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
[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:
Code:

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:
Code:
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.
GreenMoose
#2 Posted : Wednesday, October 10, 2012 2:17:36 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
Hrm, when setting "Copy referenced assemblies to workspace" to True it display log output from NHibernate (as expected). Should this be necessary?
Remco
#3 Posted : Wednesday, October 10, 2012 8:18:04 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
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
GreenMoose
#4 Posted : Monday, October 15, 2012 7:54:23 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
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.
Remco
#5 Posted : Monday, October 15, 2012 8:07:04 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
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.
GreenMoose
#6 Posted : Monday, October 15, 2012 10:53:29 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
I used NCrunch's config option "Additional files to include".
1 user thanked GreenMoose for this useful post.
Remco on 10/15/2012(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.041 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download