當前位置: 首頁>>代碼示例>>Java>>正文


Java DOMConfigurator.configure方法代碼示例

本文整理匯總了Java中org.apache.log4j.xml.DOMConfigurator.configure方法的典型用法代碼示例。如果您正苦於以下問題:Java DOMConfigurator.configure方法的具體用法?Java DOMConfigurator.configure怎麽用?Java DOMConfigurator.configure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.log4j.xml.DOMConfigurator的用法示例。


在下文中一共展示了DOMConfigurator.configure方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loading

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
@Override
public void loading() throws AlbianServiceException {
	try {
		Thread.currentThread().setContextClassLoader(AlbianClassLoader.getInstance());  
		if (KernelSetting.getAlbianConfigFilePath().startsWith("http://")) {
			DOMConfigurator.configure(new URL(Path
					.getExtendResourcePath(KernelSetting
							.getAlbianConfigFilePath() + "log4j.xml")));
		} else {

			DOMConfigurator.configure(Path
					.getExtendResourcePath(KernelSetting
							.getAlbianConfigFilePath() + "log4j.xml"));
		}

		super.loading();
		loggers = new ConcurrentHashMap<String, Logger>();
		// logger = LoggerFactory.getLogger(ALBIAN_LOGGER);
	} catch (Exception exc) {
		throw new AlbianServiceException(exc.getMessage(), exc.getCause());
	}
}
 
開發者ID:crosg,項目名稱:Albianj2,代碼行數:23,代碼來源:AlbianLoggerService.java

示例2: main

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
public static void main(final String[] args) {
    final String log4jConfiguration = System.getProperties().getProperty("log4j.configuration");
    if (StringUtils.isNotBlank(log4jConfiguration)) {
        final String parsedConfiguration = PathUtils.clean(StringUtils.removeStart(log4jConfiguration, "file:"));
        final File configFile = new File(parsedConfiguration);
        if (configFile.exists()) {
            DOMConfigurator.configure(parsedConfiguration);
        } else {
            BasicConfigurator.configure();
        }
    }
    log.info("Starting Merge Tool");

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(final Thread thread, final Throwable throwable) {
            log.error("Uncaught exception in " + thread.getName(), throwable);
        }
    });

    final int returnCode = setupAndRun(args);

    log.info("Finished running Merge Tool");

    System.exit(returnCode);
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:27,代碼來源:MergeTool.java

示例3: main

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
/**
 * <p>
 * main.
 * </p>
 *
 * @param args a {@link java.lang.String} object.
 * @throws java.lang.Throwable if any.
 */
public static void main(final String... args) throws Throwable
{
    final AppContext cfg = new AppContext(workDir());

    LogManager.resetConfiguration();
    DOMConfigurator.configure(cfg.log4jConfigFileName);

    try
    {
        Funnel.sort(cfg, args);

    } catch (final ParseException e)
    {
        System.out.println(e.getMessage());
    }

    System.exit(0);
}
 
開發者ID:fedups,項目名稱:com.obdobion.funnelsort,代碼行數:27,代碼來源:App.java

示例4: main

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
/**
 * Main method for Ilves seed project.
 *
 * @param args the commandline arguments
 * @throws Exception if exception occurs in jetty startup.
 */
public static void main(final String[] args) throws Exception {
    // Configure logging.
    DOMConfigurator.configure("log4j.xml");

    // Construct jetty server.
    final Server server = Ilves.configure(PROPERTIES_FILE_PREFIX, LOCALIZATION_BUNDLE_PREFIX, PERSISTENCE_UNIT);

    // Initialize modules
    Ilves.initializeModule(AuditModule.class);
    Ilves.initializeModule(CustomerModule.class);
    Ilves.initializeModule(ContentModule.class);

    Ilves.addNavigationCategoryPage(0, "custom");
    Ilves.addChildPage("custom", "comments", DefaultValoView.class);
    Ilves.setPageComponent("comments", Slot.CONTENT, HelloComponent.class);
    Ilves.setPageComponent("comments", Slot.FOOTER, CommentingComponent.class);
    Ilves.setDefaultPage("comments");

    // Start server.
    server.start();

    // Wait for exit of the Jetty server.
    server.join();
}
 
開發者ID:bubblecloud,項目名稱:ilves-seed,代碼行數:31,代碼來源:IlvesMain.java

示例5: SPGDayUnitTest

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
/**
 * Constructs a new test with the given name.
 *
 * @param name the name of the test
 */
public SPGDayUnitTest(String name) {

  super(name);

  // Load the logging configuration
  BasicConfigurator.configure();

  try {

    DOMConfigurator.configure(new URL(System.getProperty(
        "log4j.configuration")));
  } catch (MalformedURLException mue) {

    log.error("Unable to configure logging service from XML configuration " +
              "file", mue);
  }
}
 
開發者ID:quoll,項目名稱:mulgara,代碼行數:23,代碼來源:SPGDayUnitTest.java

示例6: configureLogging

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
protected static void configureLogging(Properties properties) {
    // Init logging: Try standard log4j configuration mechanism before falling back to
    // provided logging configuration
    String log4jConfig = System.getProperty("log4j.configuration");
    if (null == log4jConfig) {
        if (properties.containsKey(PropertiesBasedServerSetupBuilder.GREENMAIL_VERBOSE)) {
            DOMConfigurator.configure(GreenMailStandaloneRunner.class.getResource("/log4j-verbose.xml"));
        } else {
            DOMConfigurator.configure(GreenMailStandaloneRunner.class.getResource("/log4j.xml"));
        }
    } else {
        if (log4jConfig.toLowerCase().endsWith(".xml")) {
            DOMConfigurator.configure(log4jConfig);
        } else {
            PropertyConfigurator.configure(log4jConfig);
        }
    }
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:19,代碼來源:GreenMailStandaloneRunner.java

示例7: init

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
@Override
@SuppressWarnings("rawtypes") 
public void init(Map params, File configDir)
        throws MetadataProviderException {
    
    // Call super's init method to handle basic Metadata Adapter features
    super.init(params, configDir);

    String logConfig = (String) params.get("log_config");
    if (logConfig != null) {
        File logConfigFile = new File(configDir, logConfig);
        String logRefresh = (String) params.get("log_config_refresh_seconds");
        if (logRefresh != null) {
            DOMConfigurator.configureAndWatch(logConfigFile.getAbsolutePath(), Integer.parseInt(logRefresh) * 1000);
        } else {
            DOMConfigurator.configure(logConfigFile.getAbsolutePath());
        }
    }
    logger = Logger.getLogger("LS_demos_Logger.StockQuotesMetadata");

    logger.info("StockQuotesMetadataAdapter ready");
}
 
開發者ID:Lightstreamer,項目名稱:Lightstreamer-example-MPNStockListMetadata-adapter-java,代碼行數:23,代碼來源:StockQuotesMetadataAdapter.java

示例8: setAppenderForLogger

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
private void setAppenderForLogger()
  {

     String cleanMac = settop.getLogDirectory();

      if ( cleanMac == null )
      {
          cleanMac = "UnknownMac";
      }
Map<String,String> mdcMap = new HashMap<String,String>();
  	mdcMap.put("SettopMac", cleanMac);
  	mdcMap.put("LogFileName", "RebootDetection.log");
      MDC.setContextMap(mdcMap);
      URL logFileUrl = getClass().getResource("/reboot-report-log4j.xml" );
      DOMConfigurator.configure( logFileUrl );
rebootDetectionLogger = LoggerFactory.getLogger("RebootDetection");
  }
 
開發者ID:Comcast,項目名稱:cats,代碼行數:18,代碼來源:RebootReporter.java

示例9: main

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
/**
 * Main method for Ilves seed project.
 *
 * @param args the commandline arguments
 * @throws Exception if exception occurs in jetty startup.
 */
public static void main(final String[] args) throws Exception {
    // Configure logging.
    DOMConfigurator.configure("log4j.xml");

    // Construct jetty server.
    final Server server = Ilves.configure(PROPERTIES_FILE_PREFIX, LOCALIZATION_BUNDLE_PREFIX, PERSISTENCE_UNIT);

    // Initialize modules
    Ilves.initializeModule(AuditModule.class);
    Ilves.initializeModule(CustomerModule.class);
    Ilves.initializeModule(ContentModule.class);

    Ilves.addRootPage(0, "custom", DefaultValoView.class);
    Ilves.setPageComponent("custom", Slot.CONTENT, WelcomeComponent.class);
    Ilves.setPageComponent("custom", Slot.FOOTER, CommentingComponent.class);
    Ilves.setDefaultPage("custom");

    // Start server.
    server.start();

    // Wait for exit of the Jetty server.
    server.join();
}
 
開發者ID:bubblecloud,項目名稱:ilves-war-seed,代碼行數:30,代碼來源:IlvesMain.java

示例10: reloadConfig

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
private void reloadConfig() throws MalformedURLException, FactoryConfigurationError, BException {
  String blurHome = System.getenv("BLUR_HOME");
  if (blurHome != null) {
    File blurHomeFile = new File(blurHome);
    if (blurHomeFile.exists()) {
      File log4jFile = new File(new File(blurHomeFile, "conf"), "log4j.xml");
      if (log4jFile.exists()) {
        LOG.info("Reseting log4j config from [{0}]", log4jFile);
        LogManager.resetConfiguration();
        DOMConfigurator.configure(log4jFile.toURI().toURL());
        return;
      }
    }
  }
  URL url = TableAdmin.class.getResource("/log4j.xml");
  if (url != null) {
    LOG.info("Reseting log4j config from classpath resource [{0}]", url);
    LogManager.resetConfiguration();
    DOMConfigurator.configure(url);
    return;
  }
  throw new BException("Could not locate log4j file to reload, doing nothing.");
}
 
開發者ID:apache,項目名稱:incubator-blur,代碼行數:24,代碼來源:TableAdmin.java

示例11: loadLoggingConfig

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
/**
 * Loads the embedded logging configuration (from the JAR file).
 */
private void loadLoggingConfig() {
  // get a URL from the classloader for the logging configuration
  URL log4jConfigUrl = ClassLoader.getSystemResource(LOG4J_CONFIG_PATH);

  // if we didn't get a URL, tell the user that something went wrong
  if (log4jConfigUrl == null) {
    System.err.println("Unable to find logging configuration file in JAR " +
        "with " + LOG4J_CONFIG_PATH + ", reverting to default configuration.");
    BasicConfigurator.configure();
  } else {
    try {
      // configure the logging service
      DOMConfigurator.configure(log4jConfigUrl);
      log.info("Using logging configuration from " + log4jConfigUrl);
    } catch (FactoryConfigurationError e) {
      System.err.println("Unable to configure logging service");
    }
  }
}
 
開發者ID:quoll,項目名稱:mulgara,代碼行數:23,代碼來源:TqlSession.java

示例12: main

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
public static void main(String[] args) throws ClassNotFoundException, SQLException, NoSuchAuthorityCodeException,
		FactoryException, TransformException, IOException {
	DOMConfigurator.configure("log4j.xml");
	VisualisationSettings set = new VisualisationSettings("mf.felk.cvut.cz", 5432, "visio", "geovisio", "visio",
			"http://mf.felk.cvut.cz:8080/geoserver", "admin", "geovisio");
	DatabaseConnection conn = new PostgisConnection(set.getDatabaseServerHost(), set.getDatabaseServerPort(),
			set.getDatabaseUser(), set.getDatabasePassword(), set.getDatabaseName());

	conn.connect();

	KmlBuilder builder = new KmlBuilder();
	// builder.addKmlItem(createPTDriverVis("tram", conn, Color.RED));
	// createPTDriverVis("bus", conn,
	// Color.CYAN).saveToKml("bus_drivers.kml");
	// createPTDriverVis("tram", conn, Color.CYAN).saveToKml("pokus.kml");
	createAgentVis("man", conn, Color.RED).saveToKml("passengers.kml");
	createTaxiVis("cabs", conn, Color.GREEN).saveToKml("taxis.kml");

	// builder.writeDataToFileAndCleanBuilder(new File("bus_drivers.kmz"));
	conn.close();
}
 
開發者ID:agents4its,項目名稱:mobilitytestbed,代碼行數:22,代碼來源:DarpTestbedFromDbToInterpolatedKmlMain.java

示例13: testAppend

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
public static void testAppend() throws Exception{
   DOMConfigurator.configure("c:/gg_test_jdbcLog.xml");

  // System.setProperty( "java.library.path", "/oracle/product/9i/bin" );
   long startTime = System.currentTimeMillis();
   for (int i = 0; i < 10000; i++) {

          cat.debug("DEBUG" );
	cat.info("INFO");
	cat.error("ERROR");
	cat.fatal("FATAL");
	
}
long endTime = System.currentTimeMillis();

System.out.println( "Total elapsed time was: " + (endTime - startTime) );

 }
 
開發者ID:NCIP,項目名稱:common-security-module,代碼行數:19,代碼來源:JDBCAppenderTest.java

示例14: initLogging

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
public static void initLogging(ServletContext servletContext) {
	if (!initialized) {
		String configFileName = servletContext.getInitParameter(CONTEXT_PARAM_LOG4J_CONFIG_LOCATION);

		if (null != configFileName && configFileName.length() > 0) {
			configFileName = servletContext.getRealPath(configFileName);

			try {
				DOMConfigurator.configure(configFileName);
				log.info(String.format("Log4j config file: %s", configFileName));
				initialized = true;
			} catch (Exception e) {
				System.err.println("ERROR: Loading log4j config file: " + configFileName + ".");
				System.err.println(e.getMessage());
			}
		}
	} else {
		log.info("Log4j already initialized");
	}

}
 
開發者ID:tilioteo,項目名稱:hypothesis,代碼行數:22,代碼來源:LogUtil.java

示例15: testSetup

import org.apache.log4j.xml.DOMConfigurator; //導入方法依賴的package包/類
@BeforeClass
public static void testSetup() throws IOException, SQLException, DAOConfigurationException {

	URL configFileResource = PostgresqlDAOTest.class.getResource("/com/ast/processserver/resources/log4j.xml");
	DOMConfigurator.configure(configFileResource);

	Config.loadProperties();

	String dataSource = "postgresql";
	DAOFactory factory = new DAOFactory(dataSource);
	connection = ConnectionPoolFactory.getConnectionPool(dataSource).getConnection();
	workspaceDAO = factory.getWorkspaceDao(connection);
	userDao = factory.getUserDao(connection);
	objectDao = factory.getItemDAO(connection);
	oversionDao = factory.getItemVersionDAO(connection);
}
 
開發者ID:stacksync,項目名稱:sync-service,代碼行數:17,代碼來源:PostgresqlDAOTest.java


注:本文中的org.apache.log4j.xml.DOMConfigurator.configure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。