Пример #1
0
        public void When_logging_using_debug()
        {
            _logger.Debug("Hi");
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, "Hi", null), Times.Once);

            var ex = new InvalidOperationException();

            _logger.Debug("Ooops", ex);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, "Ooops", ex), Times.Once);

            _logger.DebugFormat("E:{0}", 1);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, It.IsAny <string>(), null), Times.Exactly(2));

            _logger.DebugFormat("E:{0}, {1}", 1, 2);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, It.IsAny <string>(), null), Times.Exactly(3));

            _logger.DebugFormat("E:{0}, {1}, {2}", 1, 2, 3);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, It.IsAny <string>(), null), Times.Exactly(4));

            _logger.DebugFormat("E:{0}, {1}, {2}, {3}, {4}", 1, 2, 3, 4, 5);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, It.IsAny <string>(), null), Times.Exactly(5));

            var italianCulture = new CultureInfo("it-It");
            var date           = new DateTime(2000, 12, 28, 1, 4, 43, 0);

            _logger.DebugFormat(italianCulture, "Date: {0}", date);
            _mockedInnerLogger.Verify(l => l.Log(typeof(Log4NetLogger), Level.Debug, It.IsAny <string>(), null), Times.Exactly(6));
        }
Пример #2
0
        private void Log(string message)
        {
            switch (_level)
            {
            case EasyLogLevel.Debug:
                _logger.Debug(message);
                break;

            case EasyLogLevel.Info:
                _logger.Info(message);
                break;

            case EasyLogLevel.Warn:
                _logger.Warn(message);
                break;

            case EasyLogLevel.Error:
                _logger.Error(message);
                break;

            case EasyLogLevel.Fatal:
                _logger.Fatal(message);
                break;
            }
        }
Пример #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            IEasyLogger logger = logService.GetLogger <Program>();

            logger.Debug("Configuring Services");

            services.AddMvc(
                config => { config.Filters.Add(typeof(CustomExceptionFilter)); });
        }
Пример #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            IEasyLogger logger = logService.GetLogger <Program>();

            logger.Debug("Configuring MVC and Starting Application");

            app.UseStatusCodePages();
            app.UseMvc();
        }