Is there a possibility to filter out log entries from a specific thread?
I use nunit for running tests (c#):
using System;
using NUnit.Core;
using log4net;
namespace Main
{
public class Program
{
public static readonly ILogger log = LogManager.GetLogger(typeof(Program));
static void Main(string[] args)
{
log.Info("start");
TestPackage package = new TestPackage(@"C:\Test\Main.Tests.dll");
RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
remoteTestRunner.Load(package);
TestResult result = remoteTestRunner.Run(new NullListener(), TestFilter.Empty, true, LoggingThreshold.All);
log.Info("end");
}
}
}
This is the logging I get:
INFO 17:57:24 [1] Main.Program - start
ERROR 17:57:25 [TestRunnerThread] Main.TestedClass - Exception! Relevant for production / okay in test
INFO 17:57:26 [1] Main.Program - end
log4net sends me a mail every time an ERROR is logged. If I run the test, I don't want to get those mails. nunit sets the thread-name to: "TestRunnerThread". How can I ignore this thread?
I've read this: How to log into separate files per thread with Log4Net? and tried this filter (and got no logs at all):
<filter type="log4net.Filter.PropertyFilter">
<key value="threadId" />
<stringToMatch value="TestRunnerThread" />
<acceptOnMatch value="false" />
</filter>