Package org.apache.log4j.spi

Examples of org.apache.log4j.spi.Configurator


                    ", configuring Log4J from " + configURL.toExternalForm());

            String configuratorName = ctx.getInitParameter("log4j.configuratorClass");
            if (null != configuratorName)
            {
                Configurator configurator;
                try
                {
                    configurator = (Configurator) Class.forName(configuratorName).newInstance();
                } catch (Exception ex)
                {
                    ctx.log("Unable to load custom Log4J configuration class '"
                            + configuratorName + "':  " + ex.getMessage());
                    return;
                }

                configurator.doConfigure(configURL, new Hierarchy(new RootLogger(Level.OFF)));
            }
            else if (configURL.getFile().endsWith(".xml"))
                DOMConfigurator.configure(configURL);
            else
                PropertyConfigurator.configure(configURL);
View Full Code Here


   * @return An instance of the Configurator class to use
   * for reconfiguration.
   */
  protected Configurator getConfiguratorInstance() {
    // create an instance of the configurator class
    Configurator configurator = null;
   
    // if we were configured with a configurator class name, use it
    if (configuratorClassName != null) {
      configurator = (Configurator) OptionConverter.instantiateByClassName(
        configuratorClassName, Configurator.class, null);
View Full Code Here

      this.getLogger().debug("watchdog \"{}\" reconfiguring from url: {}",
        this.getName(), srcURL);
    }
   
    // create an instance of the configurator class
    Configurator configurator = getConfiguratorInstance();
   
    // if able to create configurator, then reconfigure using input stream
    if (configurator != null) {
      configurator.doConfigure(srcURL, this.getLoggerRepository());
    }
    else {
      getLogger().error(
        "watchdog \"{}\" could not create configurator, ignoring new configuration settings",
        this.getName());
View Full Code Here

    if (this.getLogger().isDebugEnabled()) {
      this.getLogger().debug("watchdog \"{}\" reconfiguring from InputStream");
    }
   
    // create an instance of the configurator class
    Configurator configurator = getConfiguratorInstance();
   
    // if able to create configurator, then reconfigure using input stream
    if (configurator != null) {
      try {
        configurator.doConfigure(srcStream, this.getLoggerRepository());
      } catch (Exception e) {
        getLogger().error(
        "watchdog " + this.getName() + " error working with configurator," +
        " ignoring new configuration settings", e);
      }
View Full Code Here

     */

static
public
void selectAndConfigure(InputStream inputStream, String clazz, LoggerRepository hierarchy) {
Configurator configurator = null;

if(clazz != null) {
  LogLog.debug("Preferred configurator class: " + clazz);
  configurator = (Configurator) instantiateByClassName(clazz,
                           Configurator.class,
                           null);
  if(configurator == null) {
   LogLog.error("Could not instantiate configurator ["+clazz+"].");
   return;
  }
} else {
  configurator = new PropertyConfigurator();
}

configurator.doConfigure(inputStream, hierarchy);
}
View Full Code Here

     @since 1.1.4 */

  static
  public
  void selectAndConfigure(URL url, String clazz, LoggerRepository hierarchy) {
   Configurator configurator = null;
   String filename = url.getFile();

   if(clazz == null && filename != null && filename.endsWith(".xml")) {
     clazz = "org.apache.log4j.xml.DOMConfigurator";
   }

   if(clazz != null) {
     LogLog.debug("Preferred configurator class: " + clazz);
     configurator = (Configurator) instantiateByClassName(clazz,
                Configurator.class,
                null);
     if(configurator == null) {
       LogLog.error("Could not instantiate configurator ["+clazz+"].");
       return;
     }
   } else {
     configurator = new PropertyConfigurator();
   }

   configurator.doConfigure(url, hierarchy);
  }
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Configuring from URL: " + url);
        }

        // Get the config delegate and target repository to config with
        Configurator delegate = null;
        try {
            delegate = getConfigurator(url);
        } catch (FileNotFoundException e) {
            return;
        }

        if (log.isTraceEnabled()) {
            log.trace("Configuring Log4j using configurator: " +
                    delegate + ", repository: " + repo);
        }

        // Now actually configure Log4j
        delegate.doConfigure(url, repo);
    }
View Full Code Here

/*     */     }
/*     */   }
/*     */
/*     */   public static void selectAndConfigure(URL url, String clazz, LoggerRepository hierarchy)
/*     */   {
/* 450 */     Configurator configurator = null;
/* 451 */     String filename = url.getFile();
/*     */
/* 453 */     if ((clazz == null) && (filename != null) && (filename.endsWith(".xml"))) {
/* 454 */       clazz = "org.apache.log4j.xml.DOMConfigurator";
/*     */     }
/*     */
/* 457 */     if (clazz != null) {
/* 458 */       LogLog.debug("Preferred configurator class: " + clazz);
/* 459 */       configurator = (Configurator)instantiateByClassName(clazz, Configurator.class, null);
/*     */
/* 462 */       if (configurator == null) {
/* 463 */         LogLog.error("Could not instantiate configurator [" + clazz + "].");
/* 464 */         return;
/*     */       }
/*     */     } else {
/* 467 */       configurator = new PropertyConfigurator();
/*     */     }
/*     */
/* 470 */     configurator.doConfigure(url, hierarchy);
/*     */   }
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Configuring from URL: " + url);
        }

        // Get the config delegate and target repository to config with
        Configurator delegate = null;
        try {
            delegate = getConfigurator(url);
        } catch (FileNotFoundException e) {
            return;
        }

        if (log.isTraceEnabled()) {
            log.trace("Configuring Log4j using configurator: " +
                    delegate + ", repository: " + repo);
        }

        // Now actually configure Log4j
        delegate.doConfigure(url, repo);
    }
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Configuring from URL: " + url);
        }

        // Get the config delegate and target repository to config with
        Configurator delegate = null;
        try {
            delegate = getConfigurator(url);
        } catch (FileNotFoundException e) {
            return;
        }

        if (log.isTraceEnabled()) {
            log.trace("Configuring Log4j using configurator: " +
                    delegate + ", repository: " + repo);
        }

        // Now actually configure Log4j
        delegate.doConfigure(url, repo);
    }
View Full Code Here

TOP

Related Classes of org.apache.log4j.spi.Configurator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.