如何配置log4net或我的Gallio测试运行器(Icarus和Echo),以便为Gallio执行日志和我自己的文件追加器使用不同的日志级别?我希望我的日志文件有一个DEBUG日志级别和Gallio有一个ERROR日志级别。
我认为这将工作,但加里奥读取两个附录:
<log4net>
<appender name="Console" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%5level [%thread] (%file:%line) - %message%newline" />
</layout>
</appender>
<appender name="File" type="log4net.Appender.FileAppender">
<file value="test.log" />
<appendToFile value="false" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%5level [%thread] (%file:%line) - %message%newline" />
</layout>
</appender>
<logger name="TestNamespace">
<level value="DEBUG" />
<appender-ref ref="File" />
</logger>
<root>
<level value="ERROR" />
<appender-ref ref="Console" />
</root>
</log4net>
Gallio正在将控制台输出重定向到其执行日志。所以我需要将ConsoleAppender的阈值设置为我想要的Gallio执行日志级别。
<log4net>
<appender name="Console" type="log4net.Appender.ConsoleAppender">
<threshold value="ERROR"/>
<layout type="log4net.Layout.PatternLayout">
<!-- Pattern to output the caller's file name and line number -->
<conversionPattern value="%5level [%thread] (%file:%line) - %message%newline" />
</layout>
</appender>
<appender name="File" type="log4net.Appender.FileAppender">
<threshold value="DEBUG"/>
<file value="test.log" />
<appendToFile value="false" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%5level [%thread] (%file:%line) - %message%newline" />
</layout>
</appender>
<root>
<appender-ref ref="Console" />
<appender-ref ref="File" />
</root>
</log4net>