在我的 NUnit 2.6 测试中,我曾经在 Visual Studio 的输出窗口的测试部分中看到 log4net 日志消息。由于我切换到 NUnit 3.2,它们不再显示,这非常不方便。我尝试搜索,我想出的最佳“解决方案”是将所有内容转储到调试字符串中,可以通过 SysInternals 的 DebugView 实用程序查看,也可以在我实际调试测试时查看 - 然后消息显示在调试部分。但是,即使没有调试,我也很想在 Visual Studio 中查看我的日志行。有任何想法吗?Visual Studio 2015。这是我当前的 log4net 配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>
</configSections>
<log4net>
<appender name="OutputDebugStringAppender" type="log4net.Appender.OutputDebugStringAppender" >
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<appender name="DebugAppender" type="log4net.Appender.DebugAppender" >
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="OutputDebugStringAppender" />
<appender-ref ref="DebugAppender" />
</root>
</log4net>
</configuration>