當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。