當前位置: 首頁>>代碼示例>>Java>>正文


Java LogManager.shutdown方法代碼示例

本文整理匯總了Java中org.apache.log4j.LogManager.shutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java LogManager.shutdown方法的具體用法?Java LogManager.shutdown怎麽用?Java LogManager.shutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.log4j.LogManager的用法示例。


在下文中一共展示了LogManager.shutdown方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureLogger

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
/**
 * Configures root logger, either for FILE output or just console.
 */
public static void configureLogger() {
    LogManager.shutdown();
    String logFile;
    if (getConfigBoolean("log.save", false)) {
        logFile = "log4j.file.properties";
    }
    else {
        logFile = "log4j.properties";
    }
    InputStream stream = Utils.class.getClassLoader().getResourceAsStream(logFile);
    if (stream == null) {
        PropertyConfigurator.configure("src/main/resources/" + logFile);
    } else {
        PropertyConfigurator.configure(stream);
    }
    logger.info("Loaded " + logFile);
    try {
        stream.close();
    } catch (IOException e) { }
}
 
開發者ID:RipMeApp,項目名稱:ripme,代碼行數:24,代碼來源:Utils.java

示例2: testWriteHeaderAndFooter

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
@Test
public void testWriteHeaderAndFooter() throws Exception
{
    initialize("TestSNSAppender/testWriteHeaderAndFooter.properties");

    logger.debug("message");

    // must retrieve writer before we shut down
    MockSNSWriter writer = appender.getMockWriter();
    LogManager.shutdown();

    assertEquals("number of messages written to log",   3,                          writer.messages.size());
    assertEquals("header is first",                     HeaderFooterLayout.HEADER,  writer.getMessage(0));
    assertEquals("message is second",                   "message",                  writer.getMessage(1));
    assertEquals("footer is last",                      HeaderFooterLayout.FOOTER,  writer.getMessage(2));
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:17,代碼來源:TestSNSAppender.java

示例3: main

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
/**
 * @param args Command line args
 */
public static void main(String[] args) {
  boolean result = false;
  try {
    ApplicationMaster appMaster = new ApplicationMaster();
    LOG.info("Initializing ApplicationMaster");
    boolean doRun = appMaster.init(args);
    if (!doRun) {
      System.exit(0);
    }
    appMaster.run();
    result = appMaster.finish();
  } catch (Throwable t) {
    LOG.fatal("Error running ApplicationMaster", t);
    LogManager.shutdown();
    ExitUtil.terminate(1, t);
  }
  if (result) {
    LOG.info("Application Master completed successfully. exiting");
    System.exit(0);
  } else {
    LOG.info("Application Master failed. exiting");
    System.exit(2);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:28,代碼來源:ApplicationMaster.java

示例4: configureAuditLogs

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
private void configureAuditLogs() throws IOException {
  // Shutdown the LogManager to release all logger open file handles.
  // Unfortunately, Apache commons logging library does not provide
  // means to release underlying loggers. For additional info look up
  // commons library FAQ.
  LogManager.shutdown();

  File file = new File(auditLogFile);
  if (file.exists()) {
    assertTrue(file.delete());
  }
  Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
  // disable logging while the cluster startup preps files
  logger.setLevel(Level.OFF);
  PatternLayout layout = new PatternLayout("%m%n");
  RollingFileAppender appender = new RollingFileAppender(layout, auditLogFile);
  logger.addAppender(appender);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:TestAuditLogs.java

示例5: testWriteHeaderAndFooter

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
@Test
public void testWriteHeaderAndFooter() throws Exception
{
    initialize("TestCloudWatchAppender/testWriteHeaderAndFooter.properties");

    logger.debug("blah blah blah");

    // must retrieve writer before we shut down
    MockCloudWatchWriter mockWriter = appender.getMockWriter();
    LogManager.shutdown();

    assertEquals("number of messages written to log", 3, mockWriter.messages.size());
    assertEquals("header is first", HeaderFooterLayout.HEADER, mockWriter.getMessage(0));
    assertEquals("footer is last",  HeaderFooterLayout.FOOTER, mockWriter.getMessage(2));
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:16,代碼來源:TestCloudWatchAppender.java

示例6: testWriteHeaderAndFooter

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
@Test
public void testWriteHeaderAndFooter() throws Exception
{
    initialize("TestKinesisAppender/testWriteHeaderAndFooter.properties");

    logger.debug("blah blah blah");

    // must retrieve writer before we shut down
    MockKinesisWriter writer = appender.getMockWriter();
    LogManager.shutdown();

    assertEquals("number of messages written to log", 3, writer.messages.size());
    assertEquals("header is first", HeaderFooterLayout.HEADER, writer.getMessage(0));
    assertEquals("footer is last",  HeaderFooterLayout.FOOTER, writer.getMessage(2));
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:16,代碼來源:TestKinesisAppender.java

示例7: syncLogsShutdown

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
public static synchronized void syncLogsShutdown(
  ScheduledExecutorService scheduler) 
{
  // flush standard streams
  //
  System.out.flush();
  System.err.flush();

  if (scheduler != null) {
    scheduler.shutdownNow();
  }

  // flush & close all appenders
  LogManager.shutdown(); 
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:16,代碼來源:TaskLog.java

示例8: destroy

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
/**
 * Destroys the server.
 * <p>
 * All services are destroyed in reverse order of initialization, then the
 * Log4j framework is shutdown.
 */
public void destroy() {
  ensureOperational();
  destroyServices();
  log.info("Server [{}] shutdown!", name);
  log.info("======================================================");
  if (!Boolean.getBoolean("test.circus")) {
    LogManager.shutdown();
  }
  status = Status.SHUTDOWN;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:Server.java

示例9: serviceStop

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
@Override
protected void serviceStop() throws Exception {
  super.serviceStop();
  LogManager.shutdown();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:6,代碼來源:MRAppMaster.java

示例10: destroyLog4j

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
private void destroyLog4j() {
    LogManager.shutdown();
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:4,代碼來源:InitApp.java

示例11: destroyLog4j

import org.apache.log4j.LogManager; //導入方法依賴的package包/類
@PreDestroy
private void destroyLog4j() {
	LogManager.shutdown();
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:5,代碼來源:JDBCAppenderConfig.java


注:本文中的org.apache.log4j.LogManager.shutdown方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。