Exemplo n.º 1
0
        public void MethodNameCategoryTest()
        {
            CategoryTraceListener categoryTraceListener = new CategoryTraceListener();

            Trace.Listeners.Clear();
            Trace.Listeners.Add(categoryTraceListener);

            ILoggerController rep = LogManager.CreateController(Guid.NewGuid().ToString());

            AppenderTrace traceAppender = new AppenderTrace();
            LayoutPattern methodLayout  = new LayoutPattern("%method");

            methodLayout.Activate();
            traceAppender.Category = methodLayout;
            traceAppender.Layout   = new LayoutLoggerSimple();
            traceAppender.Activate();

            BasicConfig.Config(rep, traceAppender);

            ILog log = LogManager.Get(rep.Name, GetType());

            log.Debug("Message");

            Assert.AreEqual(
                System.Reflection.MethodInfo.GetCurrentMethod().Name,
                categoryTraceListener.Category);
        }
Exemplo n.º 2
0
        public void DefaultCategoryTest()
        {
            CategoryTraceListener categoryTraceListener = new CategoryTraceListener();

            Trace.Listeners.Clear();
            Trace.Listeners.Add(categoryTraceListener);

            ILoggerController rep = LogManager.CreateController(Guid.NewGuid().ToString());

            AppenderTrace traceAppender = new AppenderTrace();

            traceAppender.Layout = new LayoutLoggerSimple();
            traceAppender.Activate();

            BasicConfig.Config(rep, traceAppender);

            ILog log = LogManager.Get(rep.Name, GetType());

            log.Debug("Message");

            Assert.AreEqual(
                GetType().ToString(),
                categoryTraceListener.Category);
        }