⚠️ Experimental. This library is under active development. APIs may change between minor versions without notice. Not recommended for production test suites yet. Pin to an exact version and review the changelog before upgrading.

In-memory log capture with a fluent AssertJ-style DSL for JUnit 5. Built for Quarkus and any JBoss Log Manager environment.

CI Maven Central Downloads Apache 2.0 Java 21+
Get Started View on GitHub

Why log-assert?

Fluent DSL

Filter by level, logger, message, or MDC. Chain assertions like you would with AssertJ collections.

Quarkus-native

Handles the JBoss Log Manager reset that breaks handler-based capture in @QuarkusTest.

Zero side-effects

No network I/O, no file writes, no process spawning. Safe to run in any CI environment.

Thread-safe by design

Synchronized ring-buffer. Works with parallel Maven builds and concurrent Surefire execution.


Quick Start

1. Add the dependency

<dependency>
  <groupId>io.github.usmanakram232</groupId>
  <artifactId>log-assert</artifactId>
  <version>1.0.2</version>
  <scope>test</scope>
</dependency>

2. Write your first log assertion

import static io.github.logassert.assertj.LogCaptorAssertions.assertThat;
import io.github.logassert.core.LogCaptor;
import io.github.logassert.junit5.*;

@ExtendWith(LogCaptorExtension.class)
class OrderServiceTest {

    @InjectLogCaptor
    LogCaptor logCaptor;

    @Test
    void payment_failure_is_logged() {
        orderService.processPayment(invalidRequest);

        assertThat(logCaptor)
            .atLevel(Level.ERROR)
            .fromLogger(OrderService.class)
            .single()
            .hasFormattedMessageContaining("Payment rejected")
            .hasThrowable(IllegalArgumentException.class);
    }
}

Quarkus setup

Quarkus resets the log manager after the extension class is loaded. Use @RegisterExtension static so the handler installs after that reset:

@QuarkusTest
class PaymentResourceTest {

    @RegisterExtension                       // MUST be static
    static LogCaptorExtension logExt = LogCaptorExtension.create();

    @InjectLogCaptor
    LogCaptor logCaptor;

    @Test
    void captures_payment_error() {
        assertThat(logCaptor).atLevel(Level.ERROR).isNotEmpty();
    }
}

API Reference

LogsAssert · filters (chainable)

LogsAssert · terminal assertions

LogsAssert · navigation

LogEntryAssert · single entry

Annotations


Compatibility Matrix

DependencyMinimumTested with
Java2121
JUnit 5 (junit-jupiter)5.105.11.3
AssertJ3.243.27.7
JBoss Log Manager3.03.0.6.Final
SLF4J2.02.0.16
Quarkus (optional)3.03.17.7