Esempio n. 1
0
        public void TestHierarchy1()
        {
            Log4NetDemo.Repository.Hierarchy.Hierarchy h = new Log4NetDemo.Repository.Hierarchy.Hierarchy();
            h.Root.Level = Level.Error;

            Logger a0 = (Logger)h.GetLogger("a");

            Assert.AreEqual("a", a0.Name);
            Assert.IsNull(a0.Level);
            Assert.AreSame(Level.Error, a0.EffectiveLevel);

            Logger a1 = (Logger)h.GetLogger("a");

            Assert.AreSame(a0, a1);
        }
Esempio n. 2
0
        public void TestDisable1()
        {
            CountingAppender caRoot = new CountingAppender();
            Logger           root   = ((Log4NetDemo.Repository.Hierarchy.Hierarchy)Utils.GetRepository()).Root;

            root.AddAppender(caRoot);

            Log4NetDemo.Repository.Hierarchy.Hierarchy h = ((Log4NetDemo.Repository.Hierarchy.Hierarchy)Utils.GetRepository());
            h.Threshold  = Level.Info;
            h.Configured = true;

            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.Error, MSG, null);
            Assert.AreEqual(caRoot.Counter, 6);

            h.Threshold = Level.Off;
            root.Log(Level.Debug, MSG, null);
            Assert.AreEqual(caRoot.Counter, 6);
            root.Log(Level.Info, MSG, null);
            Assert.AreEqual(caRoot.Counter, 6);
            root.Log(Level.Warn, MSG, null);
            Assert.AreEqual(caRoot.Counter, 6);
            root.Log(Level.Error, MSG, null);
            Assert.AreEqual(caRoot.Counter, 6);
            root.Log(Level.Fatal, MSG, null);
            Assert.AreEqual(caRoot.Counter, 6);
            root.Log(Level.Fatal, MSG, null);
            Assert.AreEqual(caRoot.Counter, 6);
        }
Esempio n. 3
0
 public XmlHierarchyConfigurator(Hierarchy hierarchy)
 {
     m_hierarchy   = hierarchy;
     m_appenderBag = new Hashtable();
 }