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


Java LoggerContext.stop方法代碼示例

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


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

示例1: testNoNulCharacters

import org.apache.logging.log4j.core.LoggerContext; //導入方法依賴的package包/類
public void testNoNulCharacters(final String message, final String expected) throws IOException {
    @SuppressWarnings("resource")
    final LoggerContext loggerContext = loggerContextRule.getLoggerContext();
    final Logger logger = loggerContext.getLogger("com.example");
    logger.error("log:", message);
    loggerContext.stop();
    final File file = new File(FILE_PATH);
    final byte[] contents = FileUtils.readFileToByteArray(file);
    int count0s = 0;
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < contents.length; i++) {
        final byte b = contents[i];
        if (b == 0) {
            sb.append(i);
            sb.append(", ");
            count0s++;
        }
    }
    Assert.assertEquals("File contains " + count0s + " 0x00 byte at indices " + sb, 0, count0s);
    final List<String> readLines = FileUtils.readLines(file, Charset.defaultCharset());
    final String actual = readLines.get(0);
    // Assert.assertTrue(actual, actual.contains(message));
    Assert.assertEquals(actual, expected, actual);
    Assert.assertEquals(1, readLines.size());
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:26,代碼來源:CsvJsonParameterLayoutFileAppenderTest.java

示例2: tearDown

import org.apache.logging.log4j.core.LoggerContext; //導入方法依賴的package包/類
@After
public void tearDown() throws Exception {
  if (this.system != null) {
    this.system.disconnect();
    this.system = null;
  }
  // We will want to remove this at some point but right now the log context
  // does not clear out the security logconfig between tests
  LoggerContext context = (LoggerContext) LogManager.getContext(false);
  context.stop();
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:12,代碼來源:DistributedSystemLogFileJUnitTest.java

示例3: testAdvertisementsRemovedOnConfigStop

import org.apache.logging.log4j.core.LoggerContext; //導入方法依賴的package包/類
@Test
public void testAdvertisementsRemovedOnConfigStop() {
    verifyExpectedEntriesAdvertised(InMemoryAdvertiser.getAdvertisedEntries());

    final LoggerContext ctx = (LoggerContext) LogManager.getContext();
    ctx.stop();

    final Map<Object, Map<String, String>> entries = InMemoryAdvertiser.getAdvertisedEntries();
    assertTrue("Entries found: " + entries, entries.isEmpty());

    //reconfigure for subsequent testing
    ctx.start();
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:14,代碼來源:AdvertiserTest.java

示例4: testAdvertisementsAddedOnReconfigAfterStop

import org.apache.logging.log4j.core.LoggerContext; //導入方法依賴的package包/類
@Test
public void testAdvertisementsAddedOnReconfigAfterStop() {
    verifyExpectedEntriesAdvertised(InMemoryAdvertiser.getAdvertisedEntries());

    final LoggerContext ctx = (LoggerContext) LogManager.getContext();
    ctx.stop();

    final Map<Object, Map<String, String>> entries = InMemoryAdvertiser.getAdvertisedEntries();
    assertTrue("Entries found: " + entries, entries.isEmpty());

    ctx.start();

    verifyExpectedEntriesAdvertised(InMemoryAdvertiser.getAdvertisedEntries());
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:15,代碼來源:AdvertiserTest.java

示例5: testAdvertisementsRemovedOnConfigStop

import org.apache.logging.log4j.core.LoggerContext; //導入方法依賴的package包/類
@Test
public void testAdvertisementsRemovedOnConfigStop() {
    verifyExpectedEntriesAdvertised(InMemoryAdvertiser.getAdvertisedEntries());

    final LoggerContext ctx = LoggerContext.getContext();
    ctx.stop();

    final Map<Object, Map<String, String>> entries = InMemoryAdvertiser.getAdvertisedEntries();
    assertTrue("Entries found: " + entries, entries.isEmpty());

    //reconfigure for subsequent testing
    ctx.start();
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:14,代碼來源:AdvertiserTest.java

示例6: testAdvertisementsAddedOnReconfigAfterStop

import org.apache.logging.log4j.core.LoggerContext; //導入方法依賴的package包/類
@Test
public void testAdvertisementsAddedOnReconfigAfterStop() {
    verifyExpectedEntriesAdvertised(InMemoryAdvertiser.getAdvertisedEntries());

    final LoggerContext ctx = LoggerContext.getContext();
    ctx.stop();

    final Map<Object, Map<String, String>> entries = InMemoryAdvertiser.getAdvertisedEntries();
    assertTrue("Entries found: " + entries, entries.isEmpty());

    ctx.start();

    verifyExpectedEntriesAdvertised(InMemoryAdvertiser.getAdvertisedEntries());
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:15,代碼來源:AdvertiserTest.java

示例7: shutdownTest

import org.apache.logging.log4j.core.LoggerContext; //導入方法依賴的package包/類
@Test(timeout = 5000)
public void shutdownTest() throws Exception {
    final LoggerContext ctx = (LoggerContext)LogManager.getContext(false);
    final Logger logger = ctx.getLogger("Logger");
    logger.info("This is a test");
    ctx.stop();
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:8,代碼來源:AsyncAppenderShutdownTimeoutTest.java

示例8: shutdown

import org.apache.logging.log4j.core.LoggerContext; //導入方法依賴的package包/類
public static void shutdown() {
  final LoggerContext context =
      ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()).getContext();
  context.stop();
  org.apache.logging.log4j.core.config.Configurator.shutdown(context);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:7,代碼來源:Configurator.java

示例9: shutdown

import org.apache.logging.log4j.core.LoggerContext; //導入方法依賴的package包/類
/**
 * Shuts down the given logging context.
 * @param ctx the logging context to shut down, may be null.
 */
public static void shutdown(final LoggerContext ctx) {
    if (ctx != null) {
        ctx.stop();
    }
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:10,代碼來源:Configurator.java

示例10: shutdown

import org.apache.logging.log4j.core.LoggerContext; //導入方法依賴的package包/類
/**
 * Shuts down the given logger context.
 * <p>
 * Log4j can start threads to perform certain actions like file rollovers; calling this method with a positive
 * timeout will block until the rollover thread is done.
 * </p>
 *
 * @param ctx
 *            the logger context to shut down, may be null.
 * @param timeout
 *            the maximum time to wait
 * @param timeUnit
 *            the time unit of the timeout argument
 * @return {@code true} if the logger context terminated and {@code false} if the timeout elapsed before
 *         termination.
 *
 * @see LoggerContext#stop(long, TimeUnit)
 *
 * @since 2.7
 */
public static boolean shutdown(final LoggerContext ctx, final long timeout, final TimeUnit timeUnit) {
    if (ctx != null) {
        return ctx.stop(timeout, timeUnit);
    }
    return true;
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:27,代碼來源:Configurator.java


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