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


Java Appender.close方法代码示例

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


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

示例1: verifyAuditLogsRepeat

import org.apache.log4j.Appender; //导入方法依赖的package包/类
private void verifyAuditLogsRepeat(boolean expectSuccess, int ndupe)
    throws IOException {
  // Turn off the logs
  Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
  logger.setLevel(Level.OFF);

  // Close the appenders and force all logs to be flushed
  Enumeration<?> appenders = logger.getAllAppenders();
  while (appenders.hasMoreElements()) {
    Appender appender = (Appender)appenders.nextElement();
    appender.close();
  }

  BufferedReader reader = new BufferedReader(new FileReader(auditLogFile));
  String line = null;
  boolean ret = true;

  try {
    for (int i = 0; i < ndupe; i++) {
      line = reader.readLine();
      assertNotNull(line);
      assertTrue("Expected audit event not found in audit log",
          auditPattern.matcher(line).matches());
      ret &= successPattern.matcher(line).matches();
    }
    assertNull("Unexpected event in audit log", reader.readLine());
    assertTrue("Expected success=" + expectSuccess, ret == expectSuccess);
  } finally {
    reader.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:TestAuditLogs.java

示例2: verifyAuditLogsCheckPattern

import org.apache.log4j.Appender; //导入方法依赖的package包/类
private void verifyAuditLogsCheckPattern(boolean expectSuccess, int ndupe, Pattern pattern)
    throws IOException {
  // Turn off the logs
  Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
  logger.setLevel(Level.OFF);

  // Close the appenders and force all logs to be flushed
  Enumeration<?> appenders = logger.getAllAppenders();
  while (appenders.hasMoreElements()) {
    Appender appender = (Appender)appenders.nextElement();
    appender.close();
  }

  BufferedReader reader = new BufferedReader(new FileReader(auditLogFile));
  String line = null;
  boolean ret = true;
  boolean patternMatches = false;

  try {
      for (int i = 0; i < ndupe; i++) {
        line = reader.readLine();
        assertNotNull(line);
        patternMatches |= pattern.matcher(line).matches();
        ret &= successPattern.matcher(line).matches();
      }
      assertNull("Unexpected event in audit log", reader.readLine());
      assertTrue("Expected audit event not found in audit log", patternMatches);
      assertTrue("Expected success=" + expectSuccess, ret == expectSuccess);
    } finally {
      reader.close();
    }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:TestAuditLogs.java

示例3: removeLog4jAppender

import org.apache.log4j.Appender; //导入方法依赖的package包/类
void removeLog4jAppender(Path path) {
    if (path == null) {
        LOG.warn("Appender name is null");
        return;
    }
    org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger();
    Appender appender = rootLogger.getAppender(path.toFile().getAbsolutePath());
    if (appender != null) {
        appender.close();
        rootLogger.removeAppender(appender);
    }
}
 
开发者ID:tascape,项目名称:reactor,代码行数:13,代码来源:AbstractCaseRunner.java

示例4: closeLogger

import org.apache.log4j.Appender; //导入方法依赖的package包/类
private static void closeLogger() {
	org.apache.log4j.LogManager.shutdown();
	Enumeration<?> e = org.apache.log4j.Logger.getRootLogger().getAllAppenders();
	while (e.hasMoreElements()) {
		Appender appender = (Appender) e.nextElement();
		appender.close();
	}
}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:9,代码来源:FeatureExtractor.java

示例5: removeAllAppenders

import org.apache.log4j.Appender; //导入方法依赖的package包/类
/**
  * Remove and close all previously attached appenders.
  * */
 public
 void removeAllAppenders() {
   if(appenderList != null) {
     int len = appenderList.size();      
     for(int i = 0; i < len; i++) {
Appender a = (Appender) appenderList.elementAt(i);
a.close();
     }
     appenderList.removeAllElements();
     appenderList = null;      
   }
 }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:16,代码来源:AppenderAttachableImpl.java

示例6: close

import org.apache.log4j.Appender; //导入方法依赖的package包/类
public void close() {
	if(_log!=null) {
		Appender a = _appender;
   		_log=null;
		layout = null;
   		if(a!=null)a.close();
   		_appender=null;
   	}
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:10,代码来源:LoggerAndSourceData.java

示例7: close

import org.apache.log4j.Appender; //导入方法依赖的package包/类
public void close() {
    //close any downstream appenders
    synchronized (downstreamAppenders) {
        flush();

        for (Enumeration enumer = downstreamAppenders.getAllAppenders();
             enumer != null && enumer.hasMoreElements();) {
            Appender appender = (Appender) enumer.nextElement();
            appender.close();
        }
    }
}
 
开发者ID:codehaus,项目名称:perf4j,代码行数:13,代码来源:GraphingStatisticsAppender.java

示例8: shutdown

import org.apache.log4j.Appender; //导入方法依赖的package包/类
/** Close all destinations*/
public void shutdown()
{
    Enumeration appenders = logger.getAllAppenders();
    while (appenders.hasMoreElements())
    {
        Appender appender = (Appender)appenders.nextElement();
        appender.close();
    }
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:11,代码来源:SimpleLog4JLogSystem.java

示例9: revert

import org.apache.log4j.Appender; //导入方法依赖的package包/类
@Override
@SuppressWarnings( "unchecked")
public void revert() {

    /*
     * This code is run on remote agent's side
     */

    /*
     * The outer code will call this method when the "needs applying" method return true.
     * 
     * Currently we could come here because of 2 reasons:
     *  - the DB appenders must be reconfigured
     *  - the user loggers must be reconfigured
     */

    if (appenderLogger != null && needsToConfigureDbAppender) {
        // there is a DB appender and it is out-of-date

        //remove the filter which will deny logging of system events
        Logger rootLogger = Logger.getRootLogger();
        Enumeration<Appender> appenders = rootLogger.getAllAppenders();
        while (appenders.hasMoreElements()) {
            Appender appender = appenders.nextElement();

            //remove the filter
            //FIXME:This is very risky, as someone may have added other filters
            //the current implementation of the filter chain in log4j will not allow
            //us to easily remove a single filter
            appender.clearFilters();
        }

        Category log;
        if ("root".equals(appenderLogger)) {
            log = Logger.getRootLogger();
        } else {
            log = Logger.getLogger(appenderLogger);
        }

        Appender dbAppender = PassiveDbAppender.getCurrentInstance(ThreadsPerCaller.getCaller());
        if (dbAppender != null) {
            //close the appender
            dbAppender.close();

            //remove it
            log.removeAppender(dbAppender);
        }
    }

    // in case we must reconfigure the custom loggers, here we should remove them from log4j, 
    // but log4j does not provide a way to do it - so we do nothing here 
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:53,代码来源:RemoteLoggingConfigurator.java

示例10: testRetryWhenTopologyMismatch

import org.apache.log4j.Appender; //导入方法依赖的package包/类
/**
 * Cluster topology mismatch shall result in DataStreamer retrying cache update with the latest topology and
 * no error logged to the console.
 *
 * @throws Exception if failed
 */
public void testRetryWhenTopologyMismatch() throws Exception {
    final int KEY = 1;
    final String VAL = "1";

    cnt = 0;

    StringWriter logWriter = new StringWriter();
    Appender logAppender = new WriterAppender(new SimpleLayout(), logWriter);

    Logger.getRootLogger().addAppender(logAppender);

    startGrids(MAX_CACHE_COUNT - 1); // cache-enabled nodes

    try (Ignite ignite = startGrid(MAX_CACHE_COUNT);
         IgniteDataStreamer<Integer, String> streamer = ignite.dataStreamer(DEFAULT_CACHE_NAME)) {

        needStaleTop = true; // simulate stale topology for the next action

        streamer.addData(KEY, VAL);
    } finally {
        needStaleTop = false;

        logWriter.flush();

        Logger.getRootLogger().removeAppender(logAppender);

        logAppender.close();
    }

    assertFalse(logWriter.toString().contains("DataStreamer will retry data transfer at stable topology"));
}
 
开发者ID:apache,项目名称:ignite,代码行数:38,代码来源:DataStreamerImplSelfTest.java


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