当前位置: 首页>>代码示例>>Java>>正文


Java ListAppender.start方法代码示例

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


在下文中一共展示了ListAppender.start方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: smoke

import ch.qos.logback.core.read.ListAppender; //导入方法依赖的package包/类
@Test
public void smoke() {
  ListAppender<ILoggingEvent> listAppender = new ListAppender<ILoggingEvent>();
  listAppender.start();
  root.addAppender(listAppender);
  Logger logger = lc.getLogger(LoggerTest.class);
  assertEquals(0, listAppender.list.size());
  logger.debug("hello");
  assertEquals(1, listAppender.list.size());
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:11,代码来源:LoggerTest.java

示例5: testMutabilityAndImmutability

import ch.qos.logback.core.read.ListAppender; //导入方法依赖的package包/类
@Test
public void testMutabilityAndImmutability() {
    final AttributeKey<Object> someAttr =
            AttributeKey.valueOf(RequestContextExportingAppenderTest.class, "SOME_ATTR");
    final RequestContextExportingAppender a = new RequestContextExportingAppender();

    // Ensure mutability before start.
    a.addBuiltIn(BuiltInProperty.ELAPSED_NANOS);
    assertThat(a.getBuiltIns()).containsExactly(BuiltInProperty.ELAPSED_NANOS);

    a.addAttribute("some-attr", someAttr);
    assertThat(a.getAttributes()).containsOnlyKeys("some-attr")
                                 .containsValue(someAttr);

    a.addHttpRequestHeader(HttpHeaderNames.USER_AGENT);
    assertThat(a.getHttpRequestHeaders()).containsExactly(HttpHeaderNames.USER_AGENT);

    a.addHttpResponseHeader(HttpHeaderNames.SET_COOKIE);
    assertThat(a.getHttpResponseHeaders()).containsExactly(HttpHeaderNames.SET_COOKIE);

    final ListAppender<ILoggingEvent> la = new ListAppender<>();
    a.addAppender(la);
    a.start();
    la.start();

    // Ensure immutability after start.
    assertThatThrownBy(() -> a.addBuiltIn(BuiltInProperty.REQ_PATH))
            .isExactlyInstanceOf(IllegalStateException.class);

    assertThatThrownBy(() -> a.addAttribute("my-attr", MY_ATTR))
            .isExactlyInstanceOf(IllegalStateException.class);

    assertThatThrownBy(() -> a.addHttpRequestHeader(HttpHeaderNames.ACCEPT))
            .isExactlyInstanceOf(IllegalStateException.class);

    assertThatThrownBy(() -> a.addHttpResponseHeader(HttpHeaderNames.DATE))
            .isExactlyInstanceOf(IllegalStateException.class);
}
 
开发者ID:line,项目名称:armeria,代码行数:39,代码来源:RequestContextExportingAppenderTest.java

示例6: prepare

import ch.qos.logback.core.read.ListAppender; //导入方法依赖的package包/类
@SafeVarargs
private final List<ILoggingEvent> prepare(Consumer<RequestContextExportingAppender>... configurators) {
    final RequestContextExportingAppender a = new RequestContextExportingAppender();
    for (Consumer<RequestContextExportingAppender> c : configurators) {
        c.accept(a);
    }

    final ListAppender<ILoggingEvent> la = new ListAppender<>();
    a.addAppender(la);
    a.start();
    la.start();
    testLogger.addAppender(a);
    return la.list;
}
 
开发者ID:line,项目名称:armeria,代码行数:15,代码来源:RequestContextExportingAppenderTest.java

示例7: add

import ch.qos.logback.core.read.ListAppender; //导入方法依赖的package包/类
public LogbackJUnitRule add(String name) {
	ListAppender<ILoggingEvent> appender = new com.github.skjolber.log.domain.test.ListAppender();
	appender.setName(name);
	
	Logger logger = (Logger) LoggerFactory.getLogger(name);
	
	logger.addAppender(appender);
	
	entries.add(new Entry(logger, appender));
	
	appender.start();
	
	return this;
}
 
开发者ID:skjolber,项目名称:json-log-domain,代码行数:15,代码来源:LogbackJUnitRule.java


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