本文整理汇总了Java中ch.qos.logback.core.testUtil.StringListAppender类的典型用法代码示例。如果您正苦于以下问题:Java StringListAppender类的具体用法?Java StringListAppender怎么用?Java StringListAppender使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringListAppender类属于ch.qos.logback.core.testUtil包,在下文中一共展示了StringListAppender类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eval
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void eval() throws JoranException {
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "callerData.xml");
String msg = "hello world";
logger.debug("toto");
logger.debug(msg);
StringListAppender<ILoggingEvent> slAppender = (StringListAppender<ILoggingEvent>) loggerContext
.getLogger("root").getAppender("STR_LIST");
assertNotNull(slAppender);
assertEquals(2, slAppender.strList.size());
assertTrue(slAppender.strList.get(0).contains(" DEBUG - toto"));
String str1 = slAppender.strList.get(1);
assertTrue(str1.contains("Caller+0"));
assertTrue(str1.contains(" DEBUG - hello world"));
}
示例2: localPropertiesShouldBeVisible
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void localPropertiesShouldBeVisible() throws JoranException {
String mdcKey = "localProperty";
String mdcVal = "" + diff;
String msg = "localPropertiesShouldBeVisible";
String prefix = "Y";
configure(SIFT_FOLDER_PREFIX + "propertyPropagation.xml");
MDC.put(mdcKey, mdcVal);
logger.debug(msg);
SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT");
StringListAppender<ILoggingEvent> listAppender = (StringListAppender<ILoggingEvent>) sa
.getAppenderTracker().find(mdcVal);
assertNotNull(listAppender);
List<String> strList = listAppender.strList;
assertEquals(1, listAppender.strList.size());
assertEquals(prefix + msg, strList.get(0));
}
示例3: propertyDefinedWithinSiftElementShouldBeVisible
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void propertyDefinedWithinSiftElementShouldBeVisible() throws JoranException {
String mdcKey = "propertyDefinedWithinSift";
String mdcVal = "" + diff;
String msg = "propertyDefinedWithinSiftElementShouldBeVisible";
String prefix = "Y";
configure(SIFT_FOLDER_PREFIX + "propertyDefinedInSiftElement.xml");
MDC.put(mdcKey, mdcVal);
logger.debug(msg);
SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT");
StringListAppender<ILoggingEvent> listAppender = (StringListAppender<ILoggingEvent>) sa
.getAppenderTracker().find(mdcVal);
assertNotNull(listAppender);
List<String> strList = listAppender.strList;
assertEquals(1, listAppender.strList.size());
assertEquals(prefix + msg, strList.get(0));
}
示例4: compositePropertyShouldCombineWithinAndWithoutSiftElement
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void compositePropertyShouldCombineWithinAndWithoutSiftElement() throws JoranException {
String mdcKey = "compositeProperty";
String mdcVal = "" + diff;
String msg = "compositePropertyShouldCombineWithinAndWithoutSiftElement";
String prefix = "composite";
configure(SIFT_FOLDER_PREFIX + "compositeProperty.xml");
MDC.put(mdcKey, mdcVal);
logger.debug(msg);
SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT");
StringListAppender<ILoggingEvent> listAppender = (StringListAppender<ILoggingEvent>) sa
.getAppenderTracker().find(mdcVal);
assertNotNull(listAppender);
List<String> strList = listAppender.strList;
assertEquals(1, listAppender.strList.size());
assertEquals(prefix + msg, strList.get(0));
}
示例5: testConversionRuleSupportInPatternLayout
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void testConversionRuleSupportInPatternLayout() throws JoranException {
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "conversionRule/patternLayout0.xml");
root.getAppender("LIST");
String msg = "Simon says";
logger.debug(msg);
StringListAppender<ILoggingEvent> sla = (StringListAppender<ILoggingEvent>) root.getAppender("LIST");
assertNotNull(sla);
assertEquals(1, sla.strList.size());
assertEquals(SampleConverter.SAMPLE_STR + " - " + msg, sla.strList.get(0));
}
示例6: replaceWithJoran
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void replaceWithJoran() throws JoranException {
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "pattern/replace0.xml");
StatusPrinter.print(lc);
root.getAppender("LIST");
String msg = "And the number is 4111111111110000, expiring on 12/2010";
logger.debug(msg);
StringListAppender<ILoggingEvent> sla = (StringListAppender<ILoggingEvent>) root.getAppender("LIST");
assertNotNull(sla);
assertEquals(1, sla.strList.size());
assertEquals("And the number is XXXX, expiring on 12/2010", sla.strList.get(0));
}
示例7: defaultLayoutRule
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void defaultLayoutRule() throws JoranException {
configure(SIFT_FOLDER_PREFIX + "defaultLayoutRule.xml");
logger.debug("hello");
SiftingAppender ha = (SiftingAppender) root.getAppender("SIFT");
StringListAppender<ILoggingEvent> listAppender = (StringListAppender<ILoggingEvent>) ha
.getAppenderTracker().find("default");
assertNotNull(listAppender);
List<String> strList = listAppender.strList;
assertEquals(1, strList.size());
assertEquals("DEBUG hello", strList.get(0));
}
示例8: testConversionRuleSupportInHtmlLayout
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void testConversionRuleSupportInHtmlLayout() throws JoranException {
configure(ClassicTestConstants.JORAN_INPUT_PREFIX
+ "conversionRule/htmlLayout0.xml");
root.getAppender("LIST");
String msg = "Simon says";
root.debug(msg);
StringListAppender<ILoggingEvent> sla = (StringListAppender<ILoggingEvent>) root
.getAppender("LIST");
assertNotNull(sla);
StatusPrinter.print(lc);
assertEquals(1, sla.strList.size());
assertFalse(sla.strList.get(0).contains("PARSER_ERROR"));
}
示例9: defaultLayout
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void defaultLayout() throws Exception {
configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/defaultLayout.xml");
StringListAppender<IAccessEvent> listAppender = (StringListAppender<IAccessEvent>) context
.getAppender("STR_LIST");
IAccessEvent event = DummyAccessEventBuilder.buildNewAccessEvent();
listAppender.doAppend(event);
assertEquals(1, listAppender.strList.size());
// the result contains a line separator at the end
assertTrue(listAppender.strList.get(0).startsWith("testMethod"));
}
示例10: setupClass
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@BeforeClass
public static void setupClass() throws Exception {
slf4jLogger = LoggerFactory.getLogger(LoggerTest.class);
context = ((ch.qos.logback.classic.Logger) slf4jLogger).getLoggerContext();
configure(CONFIG);
logger = LogManager.getLogger(LoggerTest.class);
assertTrue("Incorrect SLF4J Logger", ((SLF4JLogger) logger).getLogger() == slf4jLogger);
root = LogManager.getRootLogger();
rootLogger = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
list = (StringListAppender<ILoggingEvent>) rootLogger.getAppender("LIST");
rootLogger.detachAppender("console");
}
示例11: getListAppender
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
public static StringListAppender<ILoggingEvent> getListAppender(final SLF4JLogger slf4jLogger, final String name) {
final Logger logger = slf4jLogger.getLogger();
if (!(logger instanceof AppenderAttachable)) {
throw new AssertionError("SLF4JLogger.getLogger() did not return an instance of AppenderAttachable");
}
@SuppressWarnings("unchecked")
final AppenderAttachable<ILoggingEvent> attachable = (AppenderAttachable<ILoggingEvent>) logger;
return getListAppender(attachable, name);
}
示例12: testClassLogger
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void testClassLogger() throws Exception {
final SLF4JLogger logger = (SLF4JLogger) LogManager.getLogger("ClassLogger");
final StringListAppender<ILoggingEvent> app = TestUtil.getListAppender(logger, "Class");
logger.info("Ignored message contents.");
logger.warn("Verifying the caller class is still correct.");
logger.error("Hopefully nobody breaks me!");
final List<String> messages = app.strList;
assertEquals("Incorrect number of messages.", 3, messages.size());
for (final String message : messages) {
assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
}
}
示例13: testMethodLogger
import ch.qos.logback.core.testUtil.StringListAppender; //导入依赖的package包/类
@Test
public void testMethodLogger() throws Exception {
final SLF4JLogger logger = (SLF4JLogger) LogManager.getLogger("MethodLogger");
final StringListAppender<ILoggingEvent> app = TestUtil.getListAppender(logger, "Method");
logger.info("More messages.");
logger.warn("CATASTROPHE INCOMING!");
logger.error("ZOMBIES!!!");
logger.warn("brains~~~");
logger.info("Itchy. Tasty.");
final List<String> messages = app.strList;
assertEquals("Incorrect number of messages.", 5, messages.size());
for (final String message : messages) {
assertEquals("Incorrect caller method name.", "testMethodLogger", message);
}
}