Log4Net Multiple Projects

偶尔善良 提交于 2019-12-07 01:40:21

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/14288206/log4net-multiple-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!