/// <summary> /// Configures the <see cref="ILoggerRepository"/> using the file specified, /// monitors the file for changes and reloads the configuration if a change /// is detected. /// </summary> /// <param name="repository">The repository to configure.</param> /// <param name="configFile">The XML file to load the configuration from.</param> /// <remarks> /// <para> /// The configuration file must be valid XML. It must contain /// at least one element called <c>log4net</c> that holds /// the configuration data. /// </para> /// <para> /// The configuration file will be monitored using a <see cref="FileSystemWatcher"/> /// and depends on the behavior of that class. /// </para> /// <para> /// For more information on how to configure log4net using /// a separate configuration file, see <see cref="Configure(FileInfo)"/>. /// </para> /// </remarks> /// <seealso cref="Configure(FileInfo)"/> static public void ConfigureAndWatch(ILoggerRepository repository, FileInfo configFile) { LogLog.Debug("XmlConfigurator: configuring repository [" + repository.Name + "] using file [" + configFile + "] watching for file updates"); if (configFile == null) { LogLog.Error("XmlConfigurator: ConfigureAndWatch called with null 'configFile' parameter"); } else { // Configure log4net now Configure(repository, configFile); try { // Create a watch handler that will reload the // configuration whenever the config file is modified. ConfigureAndWatchHandler.StartWatching(repository, configFile); } catch (Exception ex) { LogLog.Error("XmlConfigurator: Failed to initialize configuration file watcher for file [" + configFile.FullName + "]", ex); } } }
/// <summary> /// Configures TracerX using the file specified, monitors the file for changes, /// and reloads the configuration if a change is detected. /// </summary> /// <param name="configFile">The XML file to load the configuration from.</param> /// <remarks> /// <para> /// The configuration file must be valid XML. It must contain /// at least one element called <c>TracerX</c> that holds /// the configuration data. /// </para> /// <para> /// The configuration file will be monitored using a <see cref="FileSystemWatcher"/> /// and depends on the behavior of that class. /// </para> /// </remarks> static public bool ConfigureAndWatch(FileInfo configFile) { bool ret = false; if (configFile == null) { EventLogging.Log("XmlConfig: ConfigureAndWatch called with null 'configStream' parameter", EventLogging.XmlConfigError); } else { // Configure TracerX now ret = Configure(configFile); try { // Create a watch handler that will reload the // configuration whenever the config file is modified. ConfigureAndWatchHandler.StartWatching(configFile); } catch (Exception ex) { EventLogging.Log("XmlConfig: Failed to initialize configuration file watcher for file [" + configFile.FullName + "]\n" + ex.ToString(), EventLogging.XmlConfigWarning); } } return(ret); }