private static void ConfigureLog4Net(ContainerBuilder containerBuilder) { XmlConfigurator.Configure(); var logManager = new LogManagerAdapter(); containerBuilder.RegisterInstance(logManager).As <ILogManager>(); }
private void ConfigureLog4net(IKernel container) { XmlConfigurator.Configure(); var logManager = new LogManagerAdapter(); container.Bind <ILogManager>().ToConstant(logManager); }
public void IsErrorEnabled_CreateAdapterWhereErrorIsEnabled_ReturnsTrue() { GetMemoryAppender("${message}", LogLevel.Error); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); Assert.IsTrue(logger.IsErrorEnabled); }
public void IsWarnEnabled_CreateAdapterWhereWarnIsNotEnabled_ReturnsFalse() { GetMemoryAppender("${message}", LogLevel.Fatal); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); Assert.IsFalse(logger.IsWarnEnabled); }
public void IsErrorEnabled_CreateAdapterWhereErrorIsNotEnabled_ReturnsFalse() { GetMemoryAppender("FATAL"); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); Assert.IsFalse(logger.IsErrorEnabled); }
public void GetLogger_SendInAnyType_ReturnsLogAdapterWithCorrectName() { var adapter = new LogManagerAdapter(); var result = (LogAdapter)adapter.GetLogger(GetType()); Assert.AreEqual(GetType().FullName, result.LoggerName); }
public void IsFatalEnabled_CreateAdapterWhereFatalIsEnabled_ReturnsTrue() { GetMemoryAppender("FATAL"); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); Assert.IsTrue(logger.IsFatalEnabled); }
public void GetLogger_SendInAnyType_ReturnsLogAdapter() { var adapter = new LogManagerAdapter(); var result = adapter.GetLogger(GetType()); Assert.IsInstanceOf <LogAdapter>(result); }
public void GetLogger_SendInAnyName_ReturnsLogAdapterWithCorrectName() { var adapter = new LogManagerAdapter(); var result = (LogAdapter)adapter.GetLogger("Any name"); Assert.AreEqual("Any name", result.LoggerName); }
private void ConfigureLog4Net() { XmlConfigurator.Configure(); var logManager = new LogManagerAdapter(); Bind <ILogManager>().ToConstant(logManager); }
private void ConfigureLog4net(ContainerBuilder builder) { XmlConfigurator.Configure(); var logManager = new LogManagerAdapter(); builder.RegisterType <LogManagerAdapter>().As <ILogManager>().SingleInstance(); }
public void IsDebugEnabled_CreateAdapterWhereDebugIsEnabled_ReturnsTrue() { GetMemoryAppender("DEBUG"); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); Assert.IsTrue(logger.IsDebugEnabled); }
private void ConfigureLog4net(IKernel container) { // we create a class because this is required to configure log4net. XmlConfigurator.Configure(); var logManager = new LogManagerAdapter(); container.Bind <ILogManager>().ToConstant(logManager); }
public void Debug_LogMessage_MessageWrittenToAdapter() { var memoryAppender = GetMemoryAppender("${message}"); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); logger.Debug("Any message"); Assert.AreEqual("Any message", memoryAppender.Logs[0]); }
public void Fatal_LogMessageToCurrentClassAdapter_MessageWrittenCurrentClassLogger() { var memoryAppender = GetMemoryAppender("${logger}"); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); logger.Fatal("Any message"); Assert.AreEqual(typeof(LogManagerAdapterTests).FullName, memoryAppender.Logs[0]); }
public void Debug_LogMessage_MessageLevelSetToDebug() { var memoryAppender = GetMemoryAppender("${level}"); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); logger.Debug("Any message"); Assert.AreEqual("Debug", memoryAppender.Logs[0]); }
public void Fatal_LogMessageWithException_ExceptionLogged() { var memoryAppender = GetMemoryAppender("${exception}"); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); logger.Fatal("Any message", new Exception("Any exception message")); Assert.AreEqual("Any exception message", memoryAppender.Logs[0]); }
public void Debug_LogMessage_MessageLevelSetToDebug() { var memoryAppender = GetMemoryAppender(); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); logger.Debug("Any message"); Assert.AreEqual("DEBUG", memoryAppender.GetEvents()[0].Level.DisplayName); }
public void Debug_LogMessageWithException_ExceptionLogged() { var memoryAppender = GetMemoryAppender(); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); logger.Debug("Any message", new Exception("Any exception message")); Assert.AreEqual("Any exception message", memoryAppender.GetEvents()[0].ExceptionObject.Message); }
public void Fatal_LogMessage_MessageWrittenToAdapter() { var memoryAppender = GetMemoryAppender(); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); logger.Fatal("Any message"); Assert.AreEqual("Any message", memoryAppender.GetEvents()[0].RenderedMessage); }
public void Debug_LogMessageToCurrentClassAdapter_MessageWrittenCurrentClassLogger() { var memoryAppender = GetMemoryAppender(); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); logger.Debug("Any message"); Assert.AreEqual(typeof(LogManagerAdapterTests).FullName, memoryAppender.GetEvents()[0].LoggerName); }
public void DebugFormat_LogMessageWithFormatProviderAndDateAndTellToFormatAsIso_DateFormatAfterIsoStandard() { var memoryAppender = GetMemoryAppender(); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); var date = new DateTime(2000, 1, 1); logger.DebugFormat(CultureInfo.InvariantCulture, "{0:s}", date); Assert.AreEqual("2000-01-01T00:00:00", memoryAppender.GetEvents()[0].RenderedMessage); }
public void FatalFormat_LogMessageWithDateAndTellToFormatAsIso_DateFormatAfterIsoStandard() { var memoryAppender = GetMemoryAppender("${message}"); var log4netManagerAdapter = new LogManagerAdapter(); var logger = log4netManagerAdapter.GetCurrentClassLogger(); var date = new DateTime(2000, 1, 1); logger.FatalFormat("{0:s}", date); Assert.AreEqual("2000-01-01T00:00:00", memoryAppender.Logs[0]); }
private static void ConfigureLog4Net(IKernel container) { if (container == null) { throw new ArgumentNullException(nameof(container)); } XmlConfigurator.Configure(); var logManager = new LogManagerAdapter(); container.Bind <ILogManager>().ToConstant(logManager); }
private static void ConfigureLogging(IApplicationController controller) { XmlConfigurator.Configure(); var logManager = new LogManagerAdapter(); controller.RegisterInstance <ILogManager>(logManager); //*** check for correct implementation // logs all unhandled exceptions AppDomain.CurrentDomain.UnhandledException += (sender, e) => { var log = logManager.GetLog(typeof(Program)); var exception = (Exception)e.ExceptionObject; log.Error(exception.ToString()); }; }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind <IUnitOfWork>().To <BodyBuildingContext>().InRequestScope(); kernel.Bind <IMuscleRepository>().To <MuscleRepository>(); kernel.Bind <IAddMuscleMaintenanceProcessor>().To <AddMuscleMaintenanceProcessor>(); XmlConfigurator.Configure(); var logManager = new LogManagerAdapter(); kernel.Bind <ILogManager>().ToConstant(logManager); var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MuscleEntityToMuscleAutoMapperTypeConfigurator()); }); //services.AddSingleton<IMapper>(sp => config.CreateMapper()) kernel.Bind <IMapper>().ToMethod(c => config.CreateMapper()).InSingletonScope(); }
private void ConfigureNLog() { var manager = new LogManagerAdapter(); container.RegisterInstance <ILogManager>(manager); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind<IUnitOfWork>().To<BodyBuildingContext>().InRequestScope(); kernel.Bind<IMuscleRepository>().To<MuscleRepository>(); kernel.Bind<IAddMuscleMaintenanceProcessor>().To<AddMuscleMaintenanceProcessor>(); XmlConfigurator.Configure(); var logManager = new LogManagerAdapter(); kernel.Bind<ILogManager>().ToConstant(logManager); var config = new MapperConfiguration(cfg => { cfg.AddProfile(new MuscleEntityToMuscleAutoMapperTypeConfigurator()); }); //services.AddSingleton<IMapper>(sp => config.CreateMapper()) kernel.Bind<IMapper>().ToMethod(c => config.CreateMapper()).InSingletonScope(); }