log4net and nunit tests, most basic example

As long as I know and used log4net with nunit, I have never used any config file, you just need to add following line in test class constructor

BasicConfigurator.Configure();

here is the full answer if you like to see the sample test class


The problem is that the NUnit test runner (when run from resharper in visual studio) runs the test from another folder (it shadow copies the test assembly), so the xml configuration is not available at that point unless you specify the full config path.

You could of course use the basic configuration and specify the logging configuration in code, like:

log4net.Config.BasicConfigurator.Configure(
  new log4net.Appender.ConsoleAppender {
    Layout = new log4net.Layout.SimpleLayout()});

You should see the log output in the test output after that.