log4net的多个项目 [英] Log4Net Multiple Projects

查看:189
本文介绍了log4net的多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的 log4net的的在我们的解决方案之一。该解决方案包含多个项目,每一个的单元测试的项目。我正在使用的这个帖子来记录添加到各种项目。

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.

例如,如果我运行测试的 Project_A 的和的 Project_B 的,我只看到记录语句的 Project_A 的(假设 Project_A的测试在测试运行第一次运行)

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)

事情我已经检查:


  • 我已经包括在每一个项目中的配置文件作为一个链接

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

我添加的 [汇编:log4net.Config.XmlConfigurator(通过ConfigFile =Log4Net.config,手表= TRUE)] 的每一个项目的汇编文件。

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.

推荐答案

想通了这个问题,我想我会在同样的困境报到他人。

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.

这篇关于log4net的多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆