• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ListAppender类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ch.qos.logback.core.read.ListAppender的典型用法代码示例。如果您正苦于以下问题:Java ListAppender类的具体用法?Java ListAppender怎么用?Java ListAppender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ListAppender类属于ch.qos.logback.core.read包,在下文中一共展示了ListAppender类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: workerThreadFlushesOnStop

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void workerThreadFlushesOnStop() {
  int loopLen = 5;
  int maxRuntime = (loopLen + 1) * Math.max(1000, delayingListAppender.delay);
  ListAppender la = delayingListAppender;
  asyncAppenderBase.addAppender(la);
  asyncAppenderBase.setDiscardingThreshold(0);
  asyncAppenderBase.setMaxFlushTime(maxRuntime);
  asyncAppenderBase.start();
  asyncAppenderBase.worker.suspend();

  for (int i = 0; i < loopLen; i++) {
    asyncAppenderBase.doAppend(i);
  }
  assertEquals(loopLen, asyncAppenderBase.getNumberOfElementsInQueue());
  assertEquals(0, la.list.size());

  asyncAppenderBase.worker.resume();
  asyncAppenderBase.stop();
  
  assertEquals(0, asyncAppenderBase.getNumberOfElementsInQueue());
  verify(la, loopLen);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:24,代码来源:AsyncAppenderBaseTest.java


示例2: testLevelFilter

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void testLevelFilter() throws JoranException {
  configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "levelFilter.xml");

  // StatusPrinter.print(loggerContext);

  logger.warn("hello");
  logger.error("to be ignored");

  @SuppressWarnings("unchecked")
  ListAppender<ILoggingEvent> listAppender = (ListAppender) root
          .getAppender("LIST");

  assertNotNull(listAppender);
  assertEquals(1, listAppender.list.size());
  ILoggingEvent back = listAppender.list.get(0);
  assertEquals(Level.WARN, back.getLevel());
  assertEquals("hello", back.getMessage());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:20,代码来源:JoranConfiguratorTest.java


示例3: testEvaluatorFilter

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void testEvaluatorFilter() throws JoranException {
  configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "evaluatorFilter.xml");

  // StatusPrinter.print(loggerContext);

  logger.warn("hello");
  logger.error("to be ignored");

  @SuppressWarnings("unchecked")
  ListAppender<ILoggingEvent> listAppender = (ListAppender) root
          .getAppender("LIST");

  assertNotNull(listAppender);
  assertEquals(1, listAppender.list.size());
  ILoggingEvent back = listAppender.list.get(0);
  assertEquals(Level.WARN, back.getLevel());
  assertEquals("hello", back.getMessage());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:20,代码来源:JoranConfiguratorTest.java


示例4: testTurboDynamicThreshold

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void testTurboDynamicThreshold() throws JoranException {
  configure(ClassicTestConstants.JORAN_INPUT_PREFIX
          + "turboDynamicThreshold.xml");

  ListAppender listAppender = (ListAppender) root.getAppender("LIST");
  assertEquals(0, listAppender.list.size());

  // this one should be denied
  MDC.put("userId", "user1");
  logger.debug("hello user1");
  // this one should log
  MDC.put("userId", "user2");
  logger.debug("hello user2");

  assertEquals(1, listAppender.list.size());
  ILoggingEvent le = (ILoggingEvent) listAppender.list.get(0);
  assertEquals("hello user2", le.getMessage());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:20,代码来源:JoranConfiguratorTest.java


示例5: testTurboDynamicThreshold2

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void testTurboDynamicThreshold2() throws JoranException {
  configure(ClassicTestConstants.JORAN_INPUT_PREFIX
          + "turboDynamicThreshold2.xml");

  ListAppender listAppender = (ListAppender) root.getAppender("LIST");
  assertEquals(0, listAppender.list.size());

  // this one should log
  MDC.put("userId", "user1");
  logger.debug("hello user1");
  // this one should log
  MDC.put("userId", "user2");
  logger.debug("hello user2");
  // this one should fail
  MDC.put("userId", "user3");
  logger.debug("hello user3");

  assertEquals(2, listAppender.list.size());
  ILoggingEvent le = (ILoggingEvent) listAppender.list.get(0);
  assertEquals("hello user1", le.getMessage());
  le = (ILoggingEvent) listAppender.list.get(1);
  assertEquals("hello user2", le.getMessage());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:25,代码来源:JoranConfiguratorTest.java


示例6: conditionalConsoleApp_IF_THEN_ELSE

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
 @Test
 public void conditionalConsoleApp_IF_THEN_ELSE() throws JoranException,
         IOException, InterruptedException {

   String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
           + "conditional/conditionalConsoleApp_ELSE.xml";
   configure(configFileAsStr);

FileAppender fileAppender = (FileAppender) root.getAppender("FILE");
   assertNotNull(fileAppender);

   ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON");
   assertNull(consoleAppender);

   ListAppender listAppender = (ListAppender) root.getAppender("LIST");
   assertNotNull(listAppender);

   // StatusPrinter.printIfErrorsOccured(context);
   StatusChecker checker = new StatusChecker(context);
   checker.assertIsErrorFree();
 }
 
开发者ID:cscfa,项目名称:bartleby,代码行数:23,代码来源:ConditionalTest.java


示例7: testWholeCycle

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void testWholeCycle() throws JoranException {
  String mdcKey = "cycle";
  configure(SIFT_FOLDER_PREFIX + "completeCycle.xml");
  MDC.put(mdcKey, "a");
  logger.debug("smoke");
  long timestamp = System.currentTimeMillis();
  SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT");
  ListAppender<ILoggingEvent> listAppender = (ListAppender<ILoggingEvent>)
          sa.getAppenderTracker().find("a");
  assertNotNull(listAppender);
  List<ILoggingEvent> eventList = listAppender.list;
  assertEquals(1, listAppender.list.size());
  assertEquals("smoke", eventList.get(0).getMessage());

  MDC.remove(mdcKey);
  LoggingEvent le = new LoggingEvent("x", logger, Level.INFO, "hello", null,
          null);
  le.setTimeStamp(timestamp + ComponentTracker.DEFAULT_TIMEOUT + 1);
  sa.doAppend(le);
  assertFalse(listAppender.isStarted());
  assertEquals(1, sa.getAppenderTracker().allKeys().size());
  assertTrue(sa.getAppenderTracker().allKeys().contains("cycleDefault"));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:25,代码来源:SiftingAppenderTest.java


示例8: QueueMessageHandler

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void getMappingForMethod_methodWithDeletionPolicyNeverWithoutParameterTypeAcknowledgment_warningMustBeLogged() throws Exception {
    // Arrange
    QueueMessageHandler queueMessageHandler = new QueueMessageHandler();
    Method receiveMethod = SqsListenerDeletionPolicyNeverNoAcknowledgment.class.getMethod("receive", String.class);

    LoggerContext logContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    ListAppender<ILoggingEvent> appender = new ListAppender<>();
    appender.start();

    Logger log = logContext.getLogger(QueueMessageHandler.class);
    log.setLevel(Level.WARN);
    log.addAppender(appender);
    appender.setContext(log.getLoggerContext());

    // Act
    queueMessageHandler.getMappingForMethod(receiveMethod, null);

    // Assert
    ILoggingEvent loggingEvent = appender.list.get(0);

    assertSame(Level.WARN, loggingEvent.getLevel());
    assertTrue(loggingEvent.getMessage().contains("receive"));
    assertTrue(loggingEvent.getMessage().contains("org.springframework.cloud.aws.messaging.listener.QueueMessageHandlerTest$SqsListenerDeletionPolicyNeverNoAcknowledgment"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:26,代码来源:QueueMessageHandlerTest.java


示例9: matches

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public boolean matches(Object actual) {
	if (actual instanceof LogbackJUnitRule) {
		LogbackJUnitRule rule = (LogbackJUnitRule) actual;
		if (matches(rule.capture())) {
			return true;
		}
	}

	if (actual instanceof ListAppender) {
		ListAppender<ILoggingEvent> appender = (ListAppender<ILoggingEvent>) actual;

		if (matches(appender.list)) {
			return true;
		}
	}

	if (actual instanceof List) {
		return matches((List<ILoggingEvent>) actual);
	}

	if (actual instanceof ILoggingEvent) {
		return matches((ILoggingEvent) actual);
	}

	return false;
}
 
开发者ID:skjolber,项目名称:json-log-domain,代码行数:28,代码来源:AbstractMatcher.java


示例10: matches

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public boolean matches(Object actual) {
	if(!initalized) {
		init();
		initalized = true;
	}
	if (actual instanceof LogbackJUnitRule) {
		LogbackJUnitRule rule = (LogbackJUnitRule) actual;
		if (matches(rule.capture())) {
			return true;
		}
	}

	if (actual instanceof ListAppender) {
		ListAppender<ILoggingEvent> appender = (ListAppender<ILoggingEvent>) actual;

		if (matches(appender.list)) {
			return true;
		}
	}

	if (actual instanceof List) {
		return matches((List<ILoggingEvent>) actual);
	}

	if (actual instanceof ILoggingEvent) {
		return matches((ILoggingEvent) actual);
	}

	return false;
}
 
开发者ID:skjolber,项目名称:json-log-domain,代码行数:32,代码来源:GenericMarkerMatcher.java


示例11: matches

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public boolean matches(Object actual) {
	if(actual instanceof LogbackJUnitRule) {
		LogbackJUnitRule rule = (LogbackJUnitRule)actual;
   		if(matches(rule.capture())) {
   			return true;
   		}
	}
	
   	if(actual instanceof ListAppender) {
   		ListAppender<ILoggingEvent> appender = (ListAppender<ILoggingEvent>)actual;
   		
   		if(matches(appender.list)) {
   			return true;
   		}
   	}
   	
   	if(actual instanceof List) {
   		return matches((List<ILoggingEvent>)actual);
   	}
   	
   	if(actual instanceof ILoggingEvent) {
   		return matches((ILoggingEvent)actual);
   	}
   	
   	return false;
   }
 
开发者ID:skjolber,项目名称:json-log-domain,代码行数:28,代码来源:MessageMatcher.java


示例12: testConfigurationMissingFileLogsWarning

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void testConfigurationMissingFileLogsWarning() throws Exception {
    final Map<String, String> configProperties = new HashMap<String, String>();
    configProperties.put(FileIdentityProvider.PROPERTY_EXPIRATION_PERIOD, FIVE_MINUTES);
    final String missingFilePath = "no/such/file";
    configProperties.put(FileIdentityProvider.PROPERTY_CREDENTIALS_FILE, missingFilePath);
    final LoginIdentityProviderConfigurationContext configContext =
            new MockLoginIdentityProviderConfigurationContext(IDENTIFIER, configProperties);
    Logger fileIdentityProviderLogger = (Logger) LoggerFactory.getLogger(FileIdentityProvider.class);
    ListAppender<ILoggingEvent> testAppender = new ListAppender<>();
    testAppender.setName("Test");
    testAppender.start();
    fileIdentityProviderLogger.addAppender(testAppender);
    final FileIdentityProvider provider = new FileIdentityProvider();

    provider.onConfigured(configContext);

    boolean fileMessageFound = false;
    for (ILoggingEvent event : testAppender.list) {
        String message = event.getFormattedMessage();
        if (message.contains(missingFilePath) && event.getLevel() == Level.WARN) {
            fileMessageFound = true;
            break;
        }
    }
    Assert.assertTrue(fileMessageFound);
}
 
开发者ID:BatchIQ,项目名称:nifi-file-identity-provider-bundle,代码行数:28,代码来源:TestFileIdentityProvider.java


示例13: setUp

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Before
public void setUp() {
    ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    setListAppender(new ListAppender<>());
    setFilter(new ThresholdFilter());
    setLogThreshold(Level.WARN);
    getFilter().start();
    getListAppender().addFilter(getFilter());
    getListAppender().start();
    root.addAppender(getListAppender());
}
 
开发者ID:altarsofmadness,项目名称:logback-slack-appender,代码行数:12,代码来源:LogbackCaptureRule.java


示例14: stopExitsWhenMaxRuntimeReached

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void stopExitsWhenMaxRuntimeReached() throws InterruptedException {
  int maxRuntime = 1;  //runtime of 0 means wait forever, so use 1 ms instead
  int loopLen = 10;
  ListAppender la = delayingListAppender;
  asyncAppenderBase.addAppender(la);
  asyncAppenderBase.setMaxFlushTime(maxRuntime);
  asyncAppenderBase.start();
  
  for (int i = 0; i < loopLen; i++) {
      asyncAppenderBase.doAppend(i);
    }
  
  asyncAppenderBase.stop();
  
  //suspend the thread so that we can make the following assertions without race conditions
  asyncAppenderBase.worker.suspend();
  
  //confirms that stop exited when runtime reached
  statusChecker.assertContainsMatch("Max queue flush timeout \\(" + maxRuntime + " ms\\) exceeded.");

  //confirms that the number of events posted are the number of events removed from the queue
  assertEquals(la.list.size(), loopLen - asyncAppenderBase.getNumberOfElementsInQueue());
  
  //resume the thread to let it finish processing
  asyncAppenderBase.worker.resume();
  
  asyncAppenderBase.worker.join();
  
  //confirms that all entries do end up being flushed if we wait long enough
  verify(la, loopLen);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:33,代码来源:AsyncAppenderBaseTest.java


示例15: buildAppender

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
public Appender<Object> buildAppender(Context context, String discriminatingValue) throws JoranException {
  ListAppender<Object> la = new ListAppender<Object>();
  la.setContext(context);
  la.setName(discriminatingValue);
  la.start();
  return la;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:8,代码来源:AppenderTrackerTest.java


示例16: setUp

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Before
public void setUp() {
  lc = new LoggerContext();
  Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
  listAppender = new ListAppender<ILoggingEvent>();
  listAppender.setContext(lc);
  listAppender.start();
  logger.addAppender(listAppender);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:10,代码来源:LoggerMessageFormattingTest.java


示例17: simpleList

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void simpleList() throws JoranException {
  configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "simpleList.xml");

  Logger logger = loggerContext.getLogger(this.getClass().getName());
  Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
  ListAppender listAppender = (ListAppender) root.getAppender("LIST");
  assertEquals(0, listAppender.list.size());
  String msg = "hello world";
  logger.debug(msg);
  assertEquals(1, listAppender.list.size());
  ILoggingEvent le = (ILoggingEvent) listAppender.list.get(0);
  assertEquals(msg, le.getMessage());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:15,代码来源:JoranConfiguratorTest.java


示例18: level

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void level() throws JoranException {
  configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "simpleLevel.xml");
  ListAppender listAppender = (ListAppender) root.getAppender("LIST");
  assertEquals(0, listAppender.list.size());
  String msg = "hello world";
  logger.debug(msg);
  assertEquals(0, listAppender.list.size());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:10,代码来源:JoranConfiguratorTest.java


示例19: rootLoggerLevelSettingBySystemProperty

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void rootLoggerLevelSettingBySystemProperty() throws JoranException {
  String propertyName = "logback.level";

  System.setProperty(propertyName, "INFO");
  configure(ClassicTestConstants.JORAN_INPUT_PREFIX
          + "rootLevelByProperty.xml");
  // StatusPrinter.print(loggerContext);
  ListAppender listAppender = (ListAppender) root.getAppender("LIST");
  assertEquals(0, listAppender.list.size());
  String msg = "hello world";
  logger.debug(msg);
  assertEquals(0, listAppender.list.size());
  System.clearProperty(propertyName);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:16,代码来源:JoranConfiguratorTest.java


示例20: loggerLevelSettingBySystemProperty

import ch.qos.logback.core.read.ListAppender; //导入依赖的package包/类
@Test
public void loggerLevelSettingBySystemProperty() throws JoranException {
  String propertyName = "logback.level";
  System.setProperty(propertyName, "DEBUG");
  configure(ClassicTestConstants.JORAN_INPUT_PREFIX
          + "loggerLevelByProperty.xml");
  // StatusPrinter.print(loggerContext);
  ListAppender listAppender = (ListAppender) root.getAppender("LIST");
  assertEquals(0, listAppender.list.size());
  String msg = "hello world";
  logger.debug(msg);
  assertEquals(1, listAppender.list.size());
  System.clearProperty(propertyName);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:15,代码来源:JoranConfiguratorTest.java



注:本文中的ch.qos.logback.core.read.ListAppender类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DataOutputBuffer类代码示例发布时间:2022-05-22
下一篇:
Java ScriptUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap