• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ConfigurationFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.logging.log4j.core.config.ConfigurationFactory的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationFactory类的具体用法?Java ConfigurationFactory怎么用?Java ConfigurationFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ConfigurationFactory类属于org.apache.logging.log4j.core.config包,在下文中一共展示了ConfigurationFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
    Thread.currentThread().setName("JukeBot-Main");

    ConfigurationFactory.setConfigurationFactory(new Log4JConfig());
    LOG = LogManager.getLogger("JukeBot");

    playerManager = new DefaultAudioPlayerManager();
    defaultPrefix = Database.getPropertyFromConfig("prefix");

    String colour = Database.getPropertyFromConfig("color");
    if (colour.equalsIgnoreCase("")) {
        LOG.error("Missing property 'color' in the database.");
        return;
    }

    embedColour = Color.decode(colour);

    playerManager.setPlayerCleanupThreshold(30000);
    playerManager.getConfiguration().setResamplingQuality(AudioConfiguration.ResamplingQuality.LOW);
    playerManager.getConfiguration().setOpusEncodingQuality(9);
    YoutubeAudioSourceManager yt = new YoutubeAudioSourceManager();
    yt.setPlaylistPageCount(Integer.MAX_VALUE);
    playerManager.registerSourceManager(yt);
    AudioSourceManagers.registerRemoteSources(playerManager);

    printBanner();

    shardManager = new DefaultShardManagerBuilder()
            .setToken(Database.getPropertyFromConfig("token"))
            .setShardsTotal(-1)
            .addEventListeners(new EventListener(), waiter)
            .setAudioSendFactory(new NativeAudioSendFactory())
            .setGame(Game.of(Game.GameType.LISTENING, defaultPrefix + "help | jukebot.xyz"))
            .build();
}
 
开发者ID:Devoxin,项目名称:JukeBot,代码行数:36,代码来源:JukeBot.java


示例2: setUpBeforeClass

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  saveLog4j2Config = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
  saveUserDir = System.getProperty("user.dir");
  saveUserHome = System.getProperty("user.home");

  julLogger = java.util.logging.Logger.getLogger("");
  saveHandlers = julLogger.getHandlers();
  for (Handler handler : saveHandlers) {
    julLogger.removeHandler(handler);
  }

  File log4j2XML = temporaryFolder_Config.newFile("log4j2.xml");
  FileUtils.writeStringToFile(log4j2XML, "<Configuration/>", APPEND);
  System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
      log4j2XML.toURI().toString());
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:GfshInitFileJUnitTest.java


示例3: tearDownAfterClass

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@AfterClass
public static void tearDownAfterClass() throws Exception {
  for (Handler handler : saveHandlers) {
    julLogger.addHandler(handler);
  }

  if (saveLog4j2Config == null) {
    System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
  } else {
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, saveLog4j2Config);
    ((LoggerContext) LogManager.getContext(false)).reconfigure();
  }

  if (saveUserDir == null) {
    System.clearProperty("user.dir");
  } else {
    System.setProperty("user.dir", saveUserDir);
  }
  if (saveUserHome == null) {
    System.clearProperty("user.home");
  } else {
    System.setProperty("user.home", saveUserHome);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:25,代码来源:GfshInitFileJUnitTest.java


示例4: tearDown

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@After
public void tearDown() throws Exception {
  Configurator.shutdown();

  System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
  if (this.beforeConfigFileProp != null) {
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
        this.beforeConfigFileProp);
  }
  StatusLogger.getLogger().setLevel(this.beforeLevel);

  LogService.reconfigure();
  assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation())
      .isTrue();

  BasicAppender.clearInstance();

  assertThat(this.systemErrRule.getLog()).isEmpty();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:20,代码来源:GeodeVerboseLogMarkerIntegrationTest.java


示例5: setUp

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  Configurator.shutdown();
  BasicAppender.clearInstance();

  this.beforeConfigFileProp =
      System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
  this.beforeLevel = StatusLogger.getLogger().getLevel();

  this.customConfigFile = createConfigFileIn(this.temporaryFolder.getRoot());

  System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
      this.customConfigFile.getAbsolutePath());
  LogService.reconfigure();
  assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation())
      .isFalse();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:CustomConfigWithLogServiceIntegrationTest.java


示例6: setUp

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  Configurator.shutdown();
  BasicAppender.clearInstance();

  this.beforeConfigFileProp =
      System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
  this.beforeLevel = StatusLogger.getLogger().getLevel();

  this.customConfigFile = createConfigFileIn(this.temporaryFolder.getRoot());

  System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
      this.customConfigFile.getAbsolutePath());

  Properties gemfireProperties = new Properties();
  gemfireProperties.put(LOCATORS, "");
  gemfireProperties.put(MCAST_PORT, "0");
  gemfireProperties.put(LOG_LEVEL, "info");
  this.cache = new CacheFactory(gemfireProperties).create();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:21,代码来源:CustomConfigWithCacheIntegrationTest.java


示例7: tearDown

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@After
public void tearDown() throws Exception {
  if (this.cache != null) {
    this.cache.getDistributedSystem().disconnect();
  }

  Configurator.shutdown();

  System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
  if (this.beforeConfigFileProp != null) {
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
        this.beforeConfigFileProp);
  }
  StatusLogger.getLogger().setLevel(this.beforeLevel);

  LogService.reconfigure();
  assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation())
      .isTrue();

  BasicAppender.clearInstance();

  assertThat(this.systemErrRule.getLog()).isEmpty();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:CustomConfigWithCacheIntegrationTest.java


示例8: setUp

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
	super.setUp();

	initLogFormatter();
	System.getProperties().setProperty(Logging.LOG_CLASS_NAME, "com.devexperts.logging.Log4j2Logging");

	// Create log file in folder that will be eventually cleared - "deleteOnExit" does not work for log files.
	BUILD_TEST_DIR.mkdirs();
	logFile = File.createTempFile("test.", ".log", BUILD_TEST_DIR);
	final Properties props = new Properties();
	props.load(Log4jCompatibilityTest.class.getResourceAsStream("/test.log4j2.properties"));
	props.setProperty("appender.file.fileName", logFile.getPath());
	LoggerContext context = (LoggerContext)LogManager.getContext(false);
	ConfigurationFactory.setConfigurationFactory(new PropertiesConfigurationFactory() {
		@Override
		public PropertiesConfiguration getConfiguration(LoggerContext loggerContext, ConfigurationSource source) {
			return new PropertiesConfigurationBuilder()
				.setConfigurationSource(source)
				.setRootProperties(props)
				.setLoggerContext(loggerContext)
				.build();
		}
	});
	context.setConfigLocation(Log4jCompatibilityTest.class.getResource("/test.log4j2.properties").toURI());
}
 
开发者ID:Devexperts,项目名称:QD,代码行数:27,代码来源:Log4j2CompatibilityTest.java


示例9: loadConfiguration

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
protected void loadConfiguration(String location, LogFile logFile) {
	Assert.notNull(location, "Location must not be null");
	if (logFile != null) {
		logFile.applyToSystemProperties();
	}
	try {
		LoggerContext ctx = getLoggerContext();
		URL url = ResourceUtils.getURL(location);
		ConfigurationSource source = getConfigurationSource(url);
		ctx.start(ConfigurationFactory.getInstance().getConfiguration(source));
	}
	catch (Exception ex) {
		throw new IllegalStateException(
				"Could not initialize Log4J2 logging from " + location, ex);
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:Log4J2LoggingSystem.java


示例10: init

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@BeforeClass
public static void init() {
    try {
        // read log4j configuration from xml
        InputStream in = new FileInputStream(new File(TestSolrAppender.class.getResource("./log4j2.xml").getPath()));
        ConfigurationFactory factory = new XMLConfigurationFactory();
        Configuration configuration = factory
                .getConfiguration(new ConfigurationSource(in));

        // init context
        context = (LoggerContext) LogManager.getContext();
        context.start(configuration);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }   
    
}
 
开发者ID:scherziglu,项目名称:log4j,代码行数:18,代码来源:TestSolrAppender.java


示例11: teardown

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@After
public void teardown() throws Exception {
    System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
    ctx.reconfigure();
    primary.stop();
    alternate.stop();
    final File file = new File("target/file-channel");
    deleteFiles(file);
    final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    final Set<ObjectName> names = server.queryNames(new ObjectName("org.apache.flume.*:*"), null);
    for (final ObjectName name : names) {
        try {
            server.unregisterMBean(name);
        } catch (final Exception ex) {
            System.out.println("Unable to unregister " + name.toString());
        }
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:19,代码来源:FlumeEmbeddedAppenderTest.java


示例12: getContext

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
/**
 * Loads the LoggerContext using the ContextSelector.
 * @param fqcn The fully qualified class name of the caller.
 * @param loader The ClassLoader to use or null.
 * @param externalContext An external context (such as a ServletContext) to be associated with the LoggerContext.
 * @param currentContext If true returns the current Context, if false returns the Context appropriate
 * for the caller if a more appropriate Context can be determined.
 * @param source The configuration source.
 * @return The LoggerContext.
 */
public LoggerContext getContext(final String fqcn, final ClassLoader loader, final Object externalContext,
                                final boolean currentContext, final ConfigurationSource source) {
    final LoggerContext ctx = selector.getContext(fqcn, loader, currentContext, null);
    if (externalContext != null && ctx.getExternalContext() == null) {
        ctx.setExternalContext(externalContext);
    }
    if (ctx.getState() == LifeCycle.State.INITIALIZED) {
        if (source != null) {
            ContextAnchor.THREAD_CONTEXT.set(ctx);
            final Configuration config = ConfigurationFactory.getInstance().getConfiguration(ctx, source);
            LOGGER.debug("Starting LoggerContext[name={}] from configuration {}", ctx.getName(), source);
            ctx.start(config);
            ContextAnchor.THREAD_CONTEXT.remove();
        } else {
            ctx.start();
        }
    }
    return ctx;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:30,代码来源:Log4jContextFactory.java


示例13: teardown

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@After
public void teardown() throws Exception {
    System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
    ctx.reconfigure();
    primary.stop();
    alternate.stop();
    final File file = new File("target/file-channel");
    final boolean result = deleteFiles(file);
    final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    final Set<ObjectName> names = server.queryNames(new ObjectName("org.apache.flume.*:*"), null);
    for (final ObjectName name : names) {
        try {
            server.unregisterMBean(name);
        } catch (final Exception ex) {
            System.out.println("Unable to unregister " + name.toString());
        }
    }
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:19,代码来源:FlumeEmbeddedAgentTest.java


示例14: setUp

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    final File file = new File("target/persistent");
    final boolean result = deleteFiles(file);

    /*
    * Clear out all other appenders associated with this logger to ensure we're
    * only hitting the Avro appender.
    */
    final int[] ports = findFreePorts(2);
    System.setProperty("primaryPort", Integer.toString(ports[0]));
    System.setProperty("alternatePort", Integer.toString(ports[1]));
    primary = new EventCollector(ports[0]);
    alternate = new EventCollector(ports[1]);
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
    ctx = (LoggerContext) LogManager.getContext(false);
    ctx.reconfigure();
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:20,代码来源:FlumePersistentPerf.java


示例15: setConfigText

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@Override
public void setConfigText(final String configText, final String charsetName) {
    LOGGER.debug("---------");
    LOGGER.debug("Remote request to reconfigure from config text.");

    try {
        final InputStream in = new ByteArrayInputStream(configText.getBytes(charsetName));
        final ConfigurationSource source = new ConfigurationSource(in);
        final Configuration updated = ConfigurationFactory.getInstance().getConfiguration(loggerContext, source);
        loggerContext.start(updated);
        LOGGER.debug("Completed remote request to reconfigure from config text.");
    } catch (final Exception ex) {
        final String msg = "Could not reconfigure from config text";
        LOGGER.error(msg, ex);
        throw new IllegalArgumentException(msg, ex);
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:18,代码来源:LoggerContextAdmin.java


示例16: setConfigText

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@Override
public void setConfigText(final String configText, final String charsetName) {
    final String old = customConfigText;
    customConfigText = Assert.isNotNull(configText, "configText");
    LOGGER.debug("---------");
    LOGGER.debug("Remote request to reconfigure from config text.");

    try {
        final InputStream in = new ByteArrayInputStream(
                configText.getBytes(charsetName));
        final ConfigurationSource source = new ConfigurationSource(in);
        final Configuration updated = ConfigurationFactory.getInstance()
                .getConfiguration(source);
        loggerContext.start(updated);
        LOGGER.debug("Completed remote request to reconfigure from config text.");
    } catch (final Exception ex) {
        customConfigText = old;
        final String msg = "Could not reconfigure from config text";
        LOGGER.error(msg, ex);
        throw new IllegalArgumentException(msg, ex);
    }
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:23,代码来源:LoggerContextAdmin.java


示例17: reconfigure

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
/**
 * Reconfigures the context.
 */
private void reconfigure(final URI configURI) {
    final ClassLoader cl = ClassLoader.class.isInstance(externalContext) ? (ClassLoader) externalContext : null;
    LOGGER.debug("Reconfiguration started for context[name={}] at URI {} ({}) with optional ClassLoader: {}",
            contextName, configURI, this, cl);
    final Configuration instance = ConfigurationFactory.getInstance().getConfiguration(this, contextName, configURI, cl);
    if (instance == null) {
        LOGGER.error("Reconfiguration failed: No configuration found for '{}' at '{}' in '{}'", contextName, configURI, cl);
    } else {
        setConfiguration(instance);
        /*
         * instance.start(); Configuration old = setConfiguration(instance); updateLoggers(); if (old != null) {
         * old.stop(); }
         */
        final String location = configuration == null ? "?" : String.valueOf(configuration.getConfigurationSource());
        LOGGER.debug("Reconfiguration complete for context[name={}] at URI {} ({}) with optional ClassLoader: {}",
                contextName, location, this, cl);
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:22,代码来源:LoggerContext.java


示例18: setUp

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    final File file = new File("target/persistent");
    deleteFiles(file);

    /*
    * Clear out all other appenders associated with this logger to ensure we're
    * only hitting the Avro appender.
    */
    final int primaryPort = AvailablePortFinder.getNextAvailable();
    final int altPort = AvailablePortFinder.getNextAvailable();
    System.setProperty("primaryPort", Integer.toString(primaryPort));
    System.setProperty("alternatePort", Integer.toString(altPort));
    primary = new EventCollector(primaryPort);
    alternate = new EventCollector(altPort);
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
    ctx = LoggerContext.getContext(false);
    ctx.reconfigure();
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:21,代码来源:FlumePersistentPerf.java


示例19: setupClass

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
@BeforeClass
public static void setupClass() {
    ThreadContext.clearAll();
    ConfigurationFactory.setConfigurationFactory(cf);
    final LoggerContext ctx = LoggerContext.getContext();
    ctx.reconfigure();
}
 
开发者ID:savantly-net,项目名称:log4j2-extended-jsonlayout,代码行数:8,代码来源:ExtendedJsonLayoutTest.java


示例20: determineStandardConfigLocations

import org.apache.logging.log4j.core.config.ConfigurationFactory; //导入依赖的package包/类
private static String[] determineStandardConfigLocations() {
    final List<String> locations = new ArrayList<>();
    for (final ConfigurationFactory factory : findFactories()) {
        for (final String extension : getSupportedTypes(factory)) {
            if ("*".equals(extension)) {
                continue;
            }
            locations.add("log4j2-test" + extension);
            locations.add("log4j2" + extension);
        }
    }
    return locations.toArray(new String[0]);
}
 
开发者ID:apache,项目名称:logging-log4j-boot,代码行数:14,代码来源:Log4jLoggingSystem.java



注:本文中的org.apache.logging.log4j.core.config.ConfigurationFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RetriesExhaustedException类代码示例发布时间:2022-05-21
下一篇:
Java PotionHelper类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap