本文整理汇总了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;
}