コード例 #1
0
        public void TestAppender2()
        {
            CountingAppender a1 = new CountingAppender();

            a1.Name = "testAppender2.1";
            CountingAppender a2 = new CountingAppender();

            a2.Name = "testAppender2.2";

            log = Utils.GetLogger("test").Logger;
            log.AddAppender(a1);
            log.AddAppender(a2);

            CountingAppender aHat = (CountingAppender)log.GetAppender(a1.Name);

            Assert.AreEqual(a1, aHat);

            aHat = (CountingAppender)log.GetAppender(a2.Name);
            Assert.AreEqual(a2, aHat);

            log.RemoveAppender("testAppender2.1");

            IEnumerator enumAppenders = ((IEnumerable)log.AppenderSet).GetEnumerator();

            Assert.IsTrue(enumAppenders.MoveNext());
            aHat = (CountingAppender)enumAppenders.Current;
            Assert.AreEqual(a2, aHat);
            Assert.IsTrue(!enumAppenders.MoveNext());

            aHat = (CountingAppender)log.GetAppender(a2.Name);
            Assert.AreEqual(a2, aHat);
        }
コード例 #2
0
        public void TestDisable1()
        {
            CountingAppender caRoot = new CountingAppender();
            ILogger          root   = Utils.GetController().Root;

            root.AddAppender(caRoot);

            ILoggerController h = Utils.GetController();

            h.Threshold = Level.Info;
            h.Initialize();

            Assert.AreEqual(caRoot.Counter, 0);

            root.Log(Level.Debug, MSG, null);
            Assert.AreEqual(caRoot.Counter, 0);
            root.Log(Level.Info, MSG, null);
            Assert.AreEqual(caRoot.Counter, 1);
            root.Log(Level.Warn, MSG, null);
            Assert.AreEqual(caRoot.Counter, 2);
            root.Log(Level.Warn, MSG, null);
            Assert.AreEqual(caRoot.Counter, 3);

            h.Threshold = Level.Warn;
            root.Log(Level.Debug, MSG, null);
            Assert.AreEqual(caRoot.Counter, 3);
            root.Log(Level.Info, MSG, null);
            Assert.AreEqual(caRoot.Counter, 3);
            root.Log(Level.Warn, MSG, null);
            Assert.AreEqual(caRoot.Counter, 4);
            root.Log(Level.Error, MSG, null);
            Assert.AreEqual(caRoot.Counter, 5);
            root.Log(Level.Assert, MSG, null);
            Assert.AreEqual(caRoot.Counter, 6);
            root.Log(Level.Exception, MSG, null);
            Assert.AreEqual(caRoot.Counter, 7);

            h.Threshold = Level.Off;
            root.Log(Level.Debug, MSG, null);
            Assert.AreEqual(caRoot.Counter, 7);
            root.Log(Level.Info, MSG, null);
            Assert.AreEqual(caRoot.Counter, 7);
            root.Log(Level.Warn, MSG, null);
            Assert.AreEqual(caRoot.Counter, 7);
            root.Log(Level.Error, MSG, null);
            Assert.AreEqual(caRoot.Counter, 7);
            root.Log(Level.Assert, MSG, null);
            Assert.AreEqual(caRoot.Counter, 7);
            root.Log(Level.Exception, MSG, null);
            Assert.AreEqual(caRoot.Counter, 7);
        }
コード例 #3
0
        public void AddingMultipleAppenders2()
        {
            CountingAppender alpha = new CountingAppender();
            CountingAppender beta  = new CountingAppender();

            BasicConfig.Config(alpha, beta);

            ILog log = LogManager.Get(GetType());

            log.Debug("Hello World");

            Assert.AreEqual(1, alpha.Counter);
            Assert.AreEqual(1, beta.Counter);
        }
コード例 #4
0
        public void TestAppender1()
        {
            log = Utils.GetLogger("test").Logger;
            CountingAppender a1 = new CountingAppender();

            a1.Name = "testAppender1";
            log.AddAppender(a1);

            IEnumerator enumAppenders = ((IEnumerable)log.AppenderSet).GetEnumerator();

            Assert.IsTrue(enumAppenders.MoveNext());
            CountingAppender aHat = (CountingAppender)enumAppenders.Current;

            Assert.AreEqual(a1, aHat);
        }
コード例 #5
0
        public void SetupRepository()
        {
            controller_ = LogManager.CreateController("");

            countingAppender_ = new CountingAppender();
            countingAppender_.Activate();

            bufferingForwardingAppender_ = new AppenderLoggerBufferForward();
            bufferingForwardingAppender_.AddAppender(countingAppender_);

            bufferingForwardingAppender_.Size = 5;
            bufferingForwardingAppender_.ClearFilter();
            //m_bufferingForwardingAppender.Fix = FixFlags.Partial;
            bufferingForwardingAppender_.Lossy        = false;
            bufferingForwardingAppender_.TriggerLossy = null;
            bufferingForwardingAppender_.Threshold    = Level.All;
        }
コード例 #6
0
        public void AddingMultipleAppenders()
        {
            CountingAppender alpha = new CountingAppender();
            CountingAppender beta  = new CountingAppender();

            ILoggerController hierarchy =
                Utils.GetController();

            hierarchy.Root.AddAppender(alpha);
            hierarchy.Root.AddAppender(beta);
            hierarchy.Initialize();

            ILog log = LogManager.Get(GetType());

            log.Debug("Hello World");

            Assert.AreEqual(1, alpha.Counter);
            Assert.AreEqual(1, beta.Counter);
        }
コード例 #7
0
        private void SetupController()
        {
            controller_ = new LoggerController();

            countingAppender_ = new CountingAppender();
            countingAppender_.Activate();

            bufferingForwardingAppender_ = new AppenderLoggerBufferForward();
            bufferingForwardingAppender_.AddAppender(countingAppender_);

            bufferingForwardingAppender_.Size = 0;
            bufferingForwardingAppender_.ClearFilter();
            bufferingForwardingAppender_.Trigger = null;
            //m_bufferingForwardingAppender.Fix = FixFlags.Partial;
            bufferingForwardingAppender_.Lossy        = false;
            bufferingForwardingAppender_.TriggerLossy = null;
            bufferingForwardingAppender_.Threshold    = Level.All;

            bufferingForwardingAppender_.Activate();

            BasicConfig.Config(controller_, bufferingForwardingAppender_);
        }