Example #1
0
        public void ReloadConfigOnTimer_When_No_Exception_Raises_ConfigurationReloadedEvent_With_Argument_Indicating_Success()
        {
            LoggingConfigurationReloadedEventArgs arguments = null;
            var loggingConfiguration = new LoggingConfiguration();

            LogManager.Configuration = loggingConfiguration;
            var logFactory = new LogFactory(loggingConfiguration);

            logFactory.ConfigurationReloaded += (sender, args) => { arguments = args; };

            logFactory.ReloadConfigOnTimer(loggingConfiguration);

            Assert.True(arguments.Succeeded);
        }
        public void ReloadConfigOnTimer_When_No_Exception_Raises_ConfigurationReloadedEvent()
        {
            var called = false;
            LoggingConfigurationReloadedEventArgs arguments = null;
            object calledBy = null;

            var configLoader         = new LoggingConfigurationWatchableFileLoader(LogFactory.DefaultAppEnvironment);
            var logFactory           = new LogFactory(configLoader);
            var loggingConfiguration = XmlLoggingConfigurationMock.CreateFromXml(logFactory, "<nlog></nlog>");

            logFactory.Configuration          = loggingConfiguration;
            logFactory.ConfigurationReloaded += (sender, args) => { called = true; calledBy = sender; arguments = args; };

            configLoader.ReloadConfigOnTimer(loggingConfiguration);

            Assert.True(called);
            Assert.Same(calledBy, logFactory);
            Assert.True(arguments.Succeeded);
        }
Example #3
0
        public void ReloadConfigOnTimer_When_No_Exception_Raises_ConfigurationReloadedEvent()
        {
            var called = false;
            LoggingConfigurationReloadedEventArgs arguments = null;
            object calledBy             = null;
            var    loggingConfiguration = new LoggingConfiguration();

            LogManager.Configuration = loggingConfiguration;
            var configLoader = new LoggingConfigurationWatchableFileLoader();
            var logFactory   = new LogFactory(configLoader);

            logFactory.Configuration          = loggingConfiguration;
            logFactory.ConfigurationReloaded += (sender, args) => { called = true; calledBy = sender; arguments = args; };

            configLoader.ReloadConfigOnTimer(loggingConfiguration);

            Assert.True(called);
            Assert.Same(calledBy, logFactory);
            Assert.True(arguments.Succeeded);
        }
 /// <summary>
 /// Event handler to be called when logging <see cref="NLog.LogManager.Configuration"/> gets reloaded.
 /// </summary>
 /// <param name="sender">Not used.</param>
 /// <param name="e">Not used.</param>
 public static void NLogConfigurationReloaded(object sender, LoggingConfigurationReloadedEventArgs e)
 {
     AddFilters(logSettings, folder);
 }
Example #5
0
 private void OnConfigReloaded(object sender, LoggingConfigurationReloadedEventArgs e)
 {
     Console.WriteLine("OnConfigReloaded success={0}", e.Succeeded);
     _reloadCounter++;
 }
Example #6
0
 private void updateConfig(object sender, LoggingConfigurationReloadedEventArgs e)
 {
     LogManager.Configuration.Variables["connectionString"] = Configuration.GetConnectionString("NLogDb");
     LogManager.Configuration.Variables["configDir"]        = "C:\\git\\damienbod\\AspNetCoreNlog\\Logs";
 }
Example #7
0
 private void OnLogManagerOnConfigurationReloaded(object sender, LoggingConfigurationReloadedEventArgs args)
 {
     Register();
 }
Example #8
0
 private void updateConfig(object sender, LoggingConfigurationReloadedEventArgs e)
 {
     LogManager.Configuration.Variables["connectionString"] = Configuration.GetConnectionString("HCPatient");
     LogManager.Configuration.Variables["configDir"]        = "C:\\Logs";
 }
Example #9
0
 private void LogManager_ConfigurationReloaded(object sender, LoggingConfigurationReloadedEventArgs e)
 {
     ExtendNLog();
 }
Example #10
0
 protected virtual void OnConfigurationReloaded(LoggingConfigurationReloadedEventArgs e)
 {
     ConfigurationReloaded?.Invoke(this, e);
 }
Example #11
0
 private void LogManagerOnConfigurationReloaded(object sender, LoggingConfigurationReloadedEventArgs loggingConfigurationReloadedEventArgs)
 {
     AttachLogTarget();
 }
Example #12
0
 private void updateConfig(object sender, LoggingConfigurationReloadedEventArgs e)
 {
     LogManager.Configuration.Variables["connectionString"] = Configuration.GetConnectionString("NLogDb");
 }
Example #13
0
 private void LogManagerOnConfigurationReloaded(object sender, LoggingConfigurationReloadedEventArgs e)
 {
     Application.Current.Dispatcher.Invoke(new Action(AttachToConfig));
 }
Example #14
0
 private static void LogManager_ConfigurationReloaded(object sender, LoggingConfigurationReloadedEventArgs e)
 {
     ExtendLogConfigurationWithTableTarget();
     Logger.Info("Logger configuration reloaded.");
 }