Exemplo n.º 1
0
        public void Test()
        {
            // Get the default hierarchy
            var h = LogManager.GetLoggerRepository() as Hierarchy;
            var m = new MemoryAppender();

            h.Root.AddAppender(m);
            log.Debug("test");
            var l1a = new L1("a");
            var l1b = new L1("b");

            l1a.L1CallL2();
            l1b.L1CallL2();
            var events = m.GetEvents();

            CheckEvent(0, events, typeof(ContextLoggerTests), "Test", "test");
            CheckEvent(1, events, typeof(L1), ".ctor", "[a] L1 logger created");
            CheckEvent(2, events, typeof(L1), ".ctor", "[b] L1 logger created");
            CheckEvent(3, events, typeof(L1), "L1CallL2", "[a] L1 calling L2");
            CheckEvent(4, events, typeof(L2), ".ctor", "[a] L2 logger created");
            CheckEvent(5, events, typeof(L2), "L2Call", "[a] L2 call");
            CheckEvent(6, events, typeof(L1), "L1CallL2", "[b] L1 calling L2");
            CheckEvent(7, events, typeof(L2), ".ctor", "[b] L2 logger created");
            CheckEvent(8, events, typeof(L2), "L2Call", "[b] L2 call");
            h.Root.RemoveAppender(m);
        }
Exemplo n.º 2
0
  public void Test() {
      // Get the default hierarchy
      var h = LogManager.GetLoggerRepository() as Hierarchy;
      var m = new MemoryAppender();
      h.Root.AddAppender(m);
      log.Debug("test");
      var l1a = new L1("a");
      var l1b = new L1("b");
      l1a.L1CallL2();
      l1b.L1CallL2();
      var events = m.GetEvents();
      CheckEvent(0, events, typeof(ContextLoggerTests), "Test", "test");
      CheckEvent(1, events, typeof(L1), ".ctor", "[a] L1 logger created");
      CheckEvent(2, events, typeof(L1), ".ctor", "[b] L1 logger created");
      CheckEvent(3, events, typeof(L1), "L1CallL2", "[a] L1 calling L2");
      CheckEvent(4, events, typeof(L2), ".ctor", "[a] L2 logger created");
      CheckEvent(5, events, typeof(L2), "L2Call", "[a] L2 call");
      CheckEvent(6, events, typeof(L1), "L1CallL2", "[b] L1 calling L2");
      CheckEvent(7, events, typeof(L2), ".ctor", "[b] L2 logger created");
      CheckEvent(8, events, typeof(L2), "L2Call", "[b] L2 call");
      h.Root.RemoveAppender(m);
 }