Log4net - confgure ignore messages from a specific stream

Is it possible to filter log entries from a specific stream?

I use nunit to run 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 log 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 mail every time ERROR is registered. If I run the test, I do not want to receive these emails. nunit sets the thread name: "TestRunnerThread". How to ignore this thread?

I read this: How to log into separate files on a stream using Log4Net? and tried this filter (and didn't get any logs at all):

<filter type="log4net.Filter.PropertyFilter">
    <key value="threadId" />
    <stringToMatch value="TestRunnerThread" />
    <acceptOnMatch value="false" />
</filter>
+5
source share
1 answer

log4net, - fake@fake.com , ...

- , , ,

, Microsoft Enterprise. .

http://msdn.microsoft.com/en-us/library/ff664569(v=pandp.50).aspx

-2

All Articles