当前位置: 首页>>代码示例>>Java>>正文


Java LoggerContext.reconfigure方法代码示例

本文整理汇总了Java中org.apache.logging.log4j.core.LoggerContext.reconfigure方法的典型用法代码示例。如果您正苦于以下问题:Java LoggerContext.reconfigure方法的具体用法?Java LoggerContext.reconfigure怎么用?Java LoggerContext.reconfigure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.logging.log4j.core.LoggerContext的用法示例。


在下文中一共展示了LoggerContext.reconfigure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LindenServer

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
public LindenServer(String conf) throws Exception {
  File lindenProperties = new File(FilenameUtils.concat(conf, LINDEN_PROPERTIES));
  File schemaXml = new File(FilenameUtils.concat(conf, SCHEMA_XML));
  Preconditions.checkArgument(lindenProperties.exists(), "can not find linden.properties.");

  lindenConf = LindenConfigBuilder.build(lindenProperties);
  if (schemaXml.exists()) {
    LindenSchema schema = LindenSchemaBuilder.build(schemaXml);
    lindenConf.setSchema(schema);
  } else {
    throw new Exception("schema.xml not found.");
  }
  port = lindenConf.getPort();
  Preconditions.checkNotNull(lindenConf.getLogPath(), "log path can not be null.");
  System.setProperty(LOG_PATH, lindenConf.getLogPath());
  System.setProperty(LOG4J_SHUTDOWN_HOOK_ENABLED, "false");
  System.setProperty(LOG4J_CONTEXT_SELECTOR, "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
  LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
  ctx.setConfigLocation(new File(FilenameUtils.concat(conf, LOG4j2_XML)).toURI());
  ctx.reconfigure();
  LOGGER = LoggerFactory.getLogger(LindenServer.class);
}
 
开发者ID:XiaoMi,项目名称:linden,代码行数:23,代码来源:LindenServer.java

示例2: loadLogger

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
/**
 * <p>
 * This method loads the required properties into log4j for the logger
 * </p>
 * 
 * @param logFileDir
 *            Log file directory
 * @param taskAttemptID
 *            The task attempt id
 * 
 * @throws IOException
 *             If any error occurs
 * @throws URISyntaxException
 * @throws SAXException
 * @throws ParserConfigurationException
 * @throws TransformerException
 */
public static void loadLogger(String logFileDir, String taskAttemptID) throws IOException, URISyntaxException, ParserConfigurationException,
		SAXException, TransformerException {
    LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
    ctx.reconfigure();
       Configuration config = ctx.getConfiguration();
       MemoryMappedFileAppender memoryMappedfileAppender = createMemoryMappedFileAppender(config, LOG_APPENDER_NAME + taskAttemptID, logFileDir, taskAttemptID, 0);
       memoryMappedfileAppender.start();
    AppenderRef[] ar = new AppenderRef [1];
       ar[0] = AppenderRef.createAppenderRef(LOG_APPENDER_NAME + taskAttemptID , Level.INFO, null);
       LoggerConfig lgf = LoggerConfig.createLogger("false",Level.INFO , LOG_CATEGORY + taskAttemptID , null, ar, null, config, null);
       config.addLogger(LOG_CATEGORY + taskAttemptID, lgf);
       ctx.getLogger(LOG_CATEGORY + taskAttemptID).addAppender(memoryMappedfileAppender);
       ctx.updateLoggers();
       ctx.start();
	mapReduceLoggers = new ArrayList<Logger>(1);
	mapReduceLoggers.add(LogManager.getLogger(LOG_CATEGORY + taskAttemptID));
	LOG.debug("Finished loading logger");

}
 
开发者ID:Impetus,项目名称:jumbune,代码行数:37,代码来源:LoggerUtil.java

示例3: updateLoggingSeverity

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
public void updateLoggingSeverity(@Observes @ConfigurationUpdate AppConfiguration appConfiguration) {
    String loggingLevel = appConfiguration.getLoggingLevel();
    if (StringHelper.isEmpty(loggingLevel)) {
        return;
    }

    log.info("Setting loggers level to: '{}'", loggingLevel);

    LoggerContext loggerContext = LoggerContext.getContext(false);

    if (StringHelper.equalsIgnoreCase("DEFAULT", loggingLevel)) {
        log.info("Reloadming log4j configuration");
        loggerContext.reconfigure();
        return;
    }

    Level level = Level.toLevel(loggingLevel, Level.INFO);

    for (org.apache.logging.log4j.core.Logger logger : loggerContext.getLoggers()) {
        String loggerName = logger.getName();
        if (loggerName.startsWith("org.xdi.service") || loggerName.startsWith("org.xdi.oxauth") || loggerName.startsWith("org.gluu")) {
            logger.setLevel(level);
        }
    }
}
 
开发者ID:GluuFederation,项目名称:oxTrust,代码行数:26,代码来源:AppInitializer.java

示例4: setExternalLoggerConfig

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
private boolean setExternalLoggerConfig() {
    log.info("External log configuration: " + appConfiguration.getExternalLoggerConfiguration());
    if (StringUtils.isEmpty(appConfiguration.getExternalLoggerConfiguration())) {
        return false;
    }
    File log4jFile = new File(appConfiguration.getExternalLoggerConfiguration());
    if (!log4jFile.exists()) {
        log.info("External log configuration does not exist.");
        return false;
    }
    LoggerContext loggerContext = LoggerContext.getContext(false);
    loggerContext.setConfigLocation(log4jFile.toURI());
    loggerContext.reconfigure();

    configurationUpdateEvent.select(ConfigurationUpdate.Literal.INSTANCE).fire(this.appConfiguration);
    return true;
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:18,代码来源:LoggerService.java

示例5: updateLoggingSeverity

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
public void updateLoggingSeverity(@Observes @ConfigurationUpdate AppConfiguration appConfiguration) {
	String loggingLevel = appConfiguration.getLoggingLevel();
	if (StringHelper.isEmpty(loggingLevel)) {
		return;
	}

	log.info("Setting loggers level to: '{}'", loggingLevel);
	
	LoggerContext loggerContext = LoggerContext.getContext(false);

	if (StringHelper.equalsIgnoreCase("DEFAULT", loggingLevel)) {
		log.info("Reloading log4j configuration");
		loggerContext.reconfigure();
		return;
	}

	Level level = Level.toLevel(loggingLevel, Level.INFO);

	for (org.apache.logging.log4j.core.Logger logger : loggerContext.getLoggers()) {
		String loggerName = logger.getName();
		if (loggerName.startsWith("org.xdi.service") || loggerName.startsWith("org.xdi.oxauth") || loggerName.startsWith("org.gluu") || level == Level.OFF) {
			logger.setLevel(level);
		}
	}
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:26,代码来源:AppInitializer.java

示例6: tearDown

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
public void tearDown() throws SQLException {
    final LoggerContext context = LoggerContext.getContext(false);
    try {
        String appenderName = "databaseAppender";
        final Appender appender = context.getConfiguration().getAppender(appenderName);
        assertNotNull("The appender '" + appenderName + "' should not be null.", appender);
        assertTrue("The appender should be a JpaAppender.", appender instanceof JpaAppender);
        ((JpaAppender) appender).getManager().close();
    } finally {
        System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
        PropertiesUtil.getProperties().reload();
        context.reconfigure();
        StatusLogger.getLogger().reset();

        try (Statement statement = this.connection.createStatement();) {
            statement.execute("SHUTDOWN");
        }

        this.connection.close();
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:22,代码来源:AbstractJpaAppenderTest.java

示例7: setUp

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

    final File file = new File("target/file-channel");
    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,代码来源:FlumeEmbeddedAgentTest.java

示例8: setUp

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的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,代码来源:FlumePersistentAppenderTest.java

示例9: setupClass

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
@BeforeClass
public static void setupClass() {
    final File file = new File(STATUS_LOG);
    file.delete();
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
    final LoggerContext ctx = (LoggerContext) LogManager.getContext();
    final Configuration config = ctx.getConfiguration();
    if (config instanceof XMLConfiguration) {
        final String name = ((XMLConfiguration) config).getName();
        if (name == null || !name.equals("XMLConfigTest")) {
            ctx.reconfigure();
        }
    } else {
        ctx.reconfigure();
    }
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:17,代码来源:AdvertiserTest.java

示例10: reInitLogConfig

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
/**
 * 根据配置文件路径初始化日志配置
 * @param logConfigpath
 */
public static void reInitLogConfig(String logConfigpath)
{
	try {
		 LoggerContext context =(LoggerContext)LogManager.getContext(false);
	     context.setConfigLocation(new File(logConfigpath).toURI());
	     context.reconfigure(); //重新初始化Log4j2的配置上下文
	     Logger log=LoggerFactory.getLogger(Log4jUtil.class);
		 log.info("日志配置重新初始化完成:"+logConfigpath);
	} catch (Exception e) {
		e.printStackTrace();
	}  
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:17,代码来源:Log4jUtil.java

示例11: setupClass

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的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

示例12: init

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
private static void init() {
  LoggerContext context = ((org.apache.logging.log4j.core.Logger) LogManager
      .getLogger(BASE_LOGGER_NAME, GemFireParameterizedMessageFactory.INSTANCE)).getContext();
  context.removePropertyChangeListener(propertyChangeListener);
  context.addPropertyChangeListener(propertyChangeListener);
  context.reconfigure(); // propertyChangeListener invokes configureFastLoggerDelegating
  configureLoggers(false, false);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:9,代码来源:LogService.java

示例13: updateLoggerConfigLocation

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
/**
 * First trying to set external logger config from GluuAppliance.
 * If there is no valid external path to log4j2.xml location then set default configuration.
 */
public void updateLoggerConfigLocation() {
    if (setExternalLoggerConfig())
        return;
    LoggerContext loggerContext = LoggerContext.getContext(false);
    loggerContext.setConfigLocation(null);
    loggerContext.reconfigure();
}
 
开发者ID:GluuFederation,项目名称:oxTrust,代码行数:12,代码来源:LoggerService.java

示例14: setExternalLoggerConfig

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
private boolean setExternalLoggerConfig() {
    GluuAppliance updateAppliance = applianceService.getAppliance();
    if (StringUtils.isEmpty(updateAppliance.getOxLogConfigLocation())) {
        return false;
    }
    File log4jFile = new File(updateAppliance.getOxLogConfigLocation());
    if (!log4jFile.exists())
        return false;
    LoggerContext loggerContext = LoggerContext.getContext(false);
    loggerContext.setConfigLocation(log4jFile.toURI());
    loggerContext.reconfigure();

    configurationUpdateEvent.select(ConfigurationUpdate.Literal.INSTANCE).fire(this.appConfiguration);
    return true;
}
 
开发者ID:GluuFederation,项目名称:oxTrust,代码行数:16,代码来源:LoggerService.java

示例15: after

import org.apache.logging.log4j.core.LoggerContext; //导入方法依赖的package包/类
@After
public void after() throws Exception {
    LoggerContext ctx = (LoggerContext) LogManager.getContext();
    ctx.reconfigure();
    executor.shutdown();
    executor.awaitTermination(1, TimeUnit.MINUTES);
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:8,代码来源:LettucePerformanceTest.java


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