Ejemplo n.º 1
0
        public void TestMethod1()
        {
            IHostEnvironment hostEnvironment = new StubHostEnvironment();

            Castle.Core.Logging.ILoggerFactory      cLoggerFactory = new OrchardLog4netFactory(hostEnvironment);
            Framework.Plugin.Logging.ILoggerFactory loggerFactory  = new CastleLoggerFactory(cLoggerFactory);
            ILogger log = loggerFactory.CreateLogger(typeof(CastleLogger));

            log4net.Config.XmlConfigurator.Configure();
            log.Error("-异常输出{0}-", 42);
            log.Warning(new ApplicationException("测试Warning输出"), "Warning");
            log.Debug(new Exception("测试Debug输出"), "姚立峰");
            // log4net记录在内存中
            //log4net.Config.BasicConfigurator.Configure(new MemoryAppender());
            //Assert.That(log, Is.Not.Null);

            //MemoryAppender.Messages.Clear();
            //log.Error("-boom{0}-", 42);
            //Assert.That(MemoryAppender.Messages, Has.Some.StringContaining("-boom42-"));

            //MemoryAppender.Messages.Clear();
            //log.Warning(new ApplicationException("problem"), "crash");
            //Assert.That(MemoryAppender.Messages, Has.Some.StringContaining("problem"));
            //Assert.That(MemoryAppender.Messages, Has.Some.StringContaining("crash"));
            //Assert.That(MemoryAppender.Messages, Has.Some.StringContaining("ApplicationException"));
        }
Ejemplo n.º 2
0
        public void TestMethod2()
        {
            ILogger logger = NullLogger.Instance;

            logger.Error("测试异常输出.");
            logger.Warning("测试Warning输出.");
            logger.Debug("测试Debug输出.");
        }