本文整理汇总了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"));
}
示例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);
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}