log4net的配置科NUnit的测试项目 [英] log4net Configuration Section for NUnit Test Project
问题描述
我正在运行NUnit的名为AssemblyTest.nunit项目。测试调用它使用log4net的集会另一个程序集。这是使用NUnit的2.4.3版与.NET 2.0框架。
I am running NUnit with the project named AssemblyTest.nunit. The test calls another assembly which uses the log4net assembly. This is using nunit version 2.4.3 with the .net 2.0 framework.
在TestFixtureSetup我打电话log4net.Config.XmlConfigurator.Configure()和我得到了以下错误:
In TestFixtureSetup I am calling log4net.Config.XmlConfigurator.Configure( ) and am getting the following error:
System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section log4net. (C:\path\to\assembly.dll.config line 7)
有没有办法来解决这个问题,而不重命名的配置文件以AssemblyTest.config?
Is there a way to fix this without renaming the config file to 'AssemblyTest.config'?
推荐答案
创建与log4net的根元素log4net的一个独立的配置文件。
Create a separate config file for log4net with root element log4net.
在TestFixtureSetup创建FileInfo对象为这个配置文件,并把它作为参数传递给log4net.Config.XmlConfigurator.Configure()。
In TestFixtureSetup create a FileInfo object for this config file and give it as argument to log4net.Config.XmlConfigurator.Configure( ).
这篇关于log4net的配置科NUnit的测试项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!