Log4Net Multiple Projects

my_overflowed_stack picture my_overflowed_stack · Jan 12, 2013 · Viewed 7.7k times · Source

I am using log4net in one of our solutions. The solution contains multiple projects, each a Unit-Test project. I am using the method described in this post to add logging to the various projects.

I am using a rolling file appender to log all of the tests to a single log file that rolls over based on the size.

Each of my projects log successfully to the log file, however, if I run tests from multiple projects (multiple test assemblies), I only see logging from the first of the assemblies.

For example, if I run tests from Project_A and Project_B, I only see logging statements from Project_A (assuming Project_A's tests were run first in the test run)

Things I have already checked:

  • I have included the config file in each project as a link

  • I have added [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)] to each project's assembly file.

  • I have tested each project separately to ensure they log successfully when run by themselves.

Answer

my_overflowed_stack picture my_overflowed_stack · Jan 14, 2013

Figured out the issue and thought I would report back for others in the same dilemma.

Each project's linked config file's property needs to change from Copy Never to Copy If Newer. Once I made this change, all projects logged to the same file as expected.