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

Notification

Icon
Error

NCrunch log4Net problem (Log files are getting locked by NCrunch)
reyou
#1 Posted : Monday, January 26, 2015 5:15:23 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/14/2015(UTC)
Posts: 3

In my integration tests I am using log4Net. Time to time I am getting

log4net:ERROR [RollingFileAppender] Unable to acquire lock on file publisher.log. The process cannot access the file 'biometrics_publisher.log' because it is being used by another process.

When I check it, NCrunch locks this file and does not release until I make force release.

Is there any resolution for this issue?
Remco
#2 Posted : Monday, January 26, 2015 9:18:44 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for posting.

NCrunch itself doesn't initiate or hold locks on these files - it has no knowledge of them. The locks are likely being held by your code under test.

There are two likely possibilities here. The first is that the tests are running in parallel and making concurrent use of the log file - see http://www.ncrunch.net/documentation/considerations-and-constraints_concurrent-use-of-test-resources for more information about this problem.

The other possibility is that the tests are not correctly closing the log file when they complete. This probably wouldn't have been an issue when running the tests outside of NCrunch as they would have been run in sequence inside the same process and probably would have used the same file handle. NCrunch, however, will call back into the process multiple times (once for each test batch in the processing queue). See http://www.ncrunch.net/documentation/considerations-and-constraints_test-atomicity for more details on this one.
GreenMoose
#3 Posted : Tuesday, January 27, 2015 9:12:43 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)
Maybe a "quickfix" can bet to set "Terminate test runner tasks when all test execution is complete" to true (if statics are keeping log files locked in a task runner process when a new process is spawned trying to aquire lock for it)?
Also you might also have luck in testing using immediate flush ( http://stackoverflow.com/a/15119184 ).
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.032 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download