Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4Net Multiple Projects

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.

like image 617
my_overflowed_stack Avatar asked Jan 11 '13 23:01

my_overflowed_stack


1 Answers

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.

like image 101
my_overflowed_stack Avatar answered Nov 04 '22 00:11

my_overflowed_stack