Using LogCaptor to unit test my logs, my issue is that with the same way as it is explained in the README I tried to use consoleCaptor.getStandardOutput() since I'm using @QuarkusTest but it gets nothing from the output, Even though the console is showing multiple json logs in the output.
@QuarkusTest
public class TestLog {
ObjectMapper mapper = new ObjectMapper();
@Test
public void testLogIsInJsonFormat() {
try (ConsoleCaptor consoleCaptor = new ConsoleCaptor()) {
QueryClass query = new QueryClass();
query.querySomeItem(null, null);
List<String> standardOutPut = consoleCaptor.getStandardOutput(); // this list returns empty
assertTrue(isValid(standardOutPut.get(1)));
}
}
}
{"timestamp":"2022-08-10T09:32:41.109+03:00","sequence":76,"loggerClassName":"org.jboss.logging.Logger","loggerName":"io.quarkus.amazon.lambda.runtime.AbstractLambdaPollLoop","level":"INFO","message":"Listening on: http://localhost:8081/_lambda_/2018-06-01/runtime/invocation/next","threadName":"Lambda Thread (TEST)","threadId":127,"mdc":{},"ndc":"","hostName":"my-laptop-name","processName":"JUnitStarter","processId":48118}
java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 0 // This means nothing was captured from the logs
My logger is @JBossLog, I suspect that maybe they are not compatible.
<dependency>
<groupId>io.github.hakky54</groupId>
<artifactId>logcaptor</artifactId>
<version>2.7.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.hakky54</groupId>
<artifactId>consolecaptor</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>