public interface LogCaptor extends SdkAutoCloseable
Can either be used stand-alone for example
try (LogCaptor logCaptor = new LogCaptor.DefaultLogCaptor(Level.INFO)) {
// Do stuff that you expect to log things
assertThat(logCaptor.loggedEvents(), is(not(empty())));
}
Or can extend it to make use of @Before / @After test annotations
class MyTestClass extends LogCaptor.LogCaptorTestBase {
@Test
public void someTestThatWeExpectToLog() {
// Do stuff that you expect to log things
assertThat(loggedEvents(), is(not(empty())));
}
}
| Modifier and Type | Interface and Description |
|---|---|
static class |
LogCaptor.DefaultLogCaptor |
static class |
LogCaptor.LogCaptorTestBase |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
static LogCaptor |
create() |
static LogCaptor |
create(org.apache.logging.log4j.Level level) |
List<org.apache.logging.log4j.core.LogEvent> |
loggedEvents() |
closeCopyright © 2026. All rights reserved.