Search code examples
log4netprofilingredgate

How do i stop log4net from logging when running tests in NUnit TestRunner


Let me explain my scenario first:

  1. I have around 2000 tests to run, which take about 30 seconds in NUnit
  2. I want to find out what's taking the time
  3. I open Ants Profiler, and get it to profile the NUnit TestRunner, and load my test dll into the TestRunner
  4. I then run the tests...

However, running the tests whilst profiling takes a lot longer (about 5 minutes to run all the tests, rather than 30 seconds). When i look through the timings in Ants Profiler, it seems log4net is being called in a lot of places, which seems to be taking up the time.

So, this is my question: how do i stop log4net logging stuff when i'm running the tests in this manner?

I can find 3 config files:

  1. In the test dll folder, there's a config.log4net file. I've put <level value="OFF" /> in there, and deleted all the appender sections
  2. In the test runner folder, there's a nunit.exe.config, and a nunit-console.exe.config file - i've put <level value="OFF" /> in both of those.
  3. I can't find any config files to play with in the ants profiler folder.

None of this seems to work, looking through the profile results i can see log4net being called, and it's definitely calling methods to output the logging information.


Solution

  • In the test setup, get the root logger and set it's log level to OFF.