当前位置: 首页>>代码示例>>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;未经允许,请勿转载。