本文整理匯總了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());
}
示例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();
}
示例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();
}
示例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());
}
示例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();
}
示例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());
}
示例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();
}
示例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);
}
示例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();
}
}
示例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;
}