我现在正忙着与Log4Net挣扎。我跟着这个post
举个例子。不同的是,在我的例子中,我有两个独立的项目,一个是所有与WebDriver和web元素交互的对象(FrameworkProject
),第二个是实际测试项目(TestProject)。我已经阅读了很多,我几乎可以肯定我已经正确设置了...
FrameworkProject程序集文件包含[assembly: log4net.Config.XmlConfigurator(Watch = true)]
我的Log4Net.config
文件如下:
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="MyAppender" />
<appender-ref ref="MyFileAppender" />
</root>
<appender name="MyAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %logger - %message%newline" />
</layout>
</appender>
<appender name="MyFileAppender" type="log4net.Appender.FileAppender">
<file value="application.log" />
<appendToFile value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %logger - %message%newline" />
</layout>
</appender>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
当我调试我的SpecFlow测试并且到达第XmlConfigurator.Configure();
行时(看上面的示例)我仍然在
log4net:ERROR Failed to find configuration section 'log4net' in the application's.
这让我很生气,我不知道可能出现什么问题。这可能是运行测试的原因??注意:我只在log4net
FrameworkProject