Logging
What a test logs
By default (pn5.logging.style=concise) Pumpo logs what a test does at INFO: one line for each page action,
HTTP request, SQL statement or Kafka operation, written when it finishes, with its outcome and duration, and one
line for each session it starts.
INFO LoggingExtension Starting test: com.example.LoginTest#logIn
INFO PumpoEvents WebApplication session 20f398bdd08ef4fc6a01e33b3836ff24 started (1.2 s)
INFO PumpoProxy ✓ LoginPage › @Navigate to https://example.test/ (612 ms)
INFO PumpoProxy ✓ LoginPage::setUsername › @SetValue for username by ID using DEFAULT strategy to value alice (231 ms)
INFO PumpoProxy ✓ LoginPage::clickLogin › @Click for kc-login (296 ms)
INFO PumpoProxy ✓ LoginPage::logInWith › @ExtendedAction with arguments [alice, ***] (0.8 s)
WARN PumpoProxy ✗ HomePage › @Wait for //iframe[contains(@src,'Home')] by XPATH (300.2 s): Error initializing page 'HomePage'. Error message: Expected condition failed: ...
INFO PumpoEvents ✓ HttpApplication › POST https://example.test/api/orders → 201 (120 ms)
INFO PumpoEvents ✓ SqlApplication › SELECT id, status FROM orders WHERE status = 'NEW' → 3 rows (45 ms)
INFO PumpoEvents ✓ SqlApplication › UPDATE orders SET status = 'PAID' WHERE id = 1 → 1 row affected (38 ms)
INFO PumpoEvents ✓ KafkaApplication › write to orders → partition 2, offset 1041 (85 ms)
INFO PumpoEvents ✓ KafkaApplication › read from orders → 2 messages (1.2 s)
WARN PumpoEvents ✗ HttpApplication › GET https://example.test/api/orders/1 (70.0 s): Exception thrown while requesting remote http agent ...
- An action is done when the next one starts, or when the page method that ran it returns or throws.
- The actions an
@ExtendedActionruns are indented under it; its own line follows them, with the duration of the whole group. - A failure is explained once, by the action that failed. The actions around it are marked ✗ without repeating it.
- The action line leaves out the timeout and default lookups. The DEBUG line logged when the action starts has every parameter.
- A
@Switchnames the option that matched and the number it returned, such as✓ LoginPage::afterLogin › @Switch for error by ID is VISIBLE → 2 (1.3 s). When no option matched, its ✗ line lists them all, joined byor. While it runs, it is@Switch (2 options). - Adding or deleting a Jamulator rule is an action line too, such as
✓ JamulatorController › add rule scopeTest. - An HTTP request shows its status; a 4xx or 5xx status is still ✓, because the request itself completed.
- A query shows how many rows it returned, and an update how many rows it changed, unless none, as for
CREATE TABLE. - URLs are shown without their query string (
?…) and with credentials masked, and cut to 150 characters. SQL statements are put on one line and cut to 120 characters. - REST Assured requests are logged the same way, whether they go through the remote driver or directly, except with direct API reporting, whose own lines record each request without its URL.
- Values registered as secrets are masked, as in every other log line.
- An action or call that runs for more than 30 seconds, such as a long
@Waitor a slow query, is logged as still running, and again every 30 seconds, so that it doesn't look like a hang:INFO PumpoProxy … HomePage › @Wait for //iframe[contains(@src,'Home')] by XPATH still running (30.0 s)pn5.logging.progresssets the number of seconds;0turns these lines off. - Where the console is not UTF-8, ✓, ✗ and … are written as
OK,FAILEDand....
Pumpo's own housekeeping, such as creating proxies, session management, connecting to the farm, test case reporting and the end of each test, is logged at DEBUG, and its internals, such as session start attempts and how a value was resolved, at TRACE.
All of Pumpo's loggers are under dev.pumpo5, so a project that logs its own code at DEBUG or TRACE can still
keep Pumpo concise:
<logger name="dev.pumpo5" level="INFO"/>
A pattern with %logger{0} shows them as before, for example PumpoProxy (logIn).
pn5.logging.style=classic restores the levels and logger names used before 0.8.127 and logs no action lines. Set it in the test
configuration, or with -Dpn5.logging.style=classic to apply it before the first test class starts.
Each test's name is also in the logback MDC under pumpo.test, so a logback pattern can show it for any
logger, for example %X{pumpo.test}.
When the run ends
When all tests have run, Pumpo logs a summary with one line per outcome, as Playwright does. The tests that need looking at are listed under their line, with their logs; the run's duration comes last:
WARN LoggingExtension ── Run summary ─────────────────────────────
1 failed
✗ com.example.OrderTest#createOrder: expected 201 but was 500
Log: target/reports/com.example.OrderTest#createOrder/pumpo5.log
1 flaky
com.example.LoginTest#logIn, which first failed: Timed out waiting for #home
Log: target/reports/com.example.LoginTest#logIn/pumpo5.log
2 skipped
1 not run
✗ com.example.ReportTest: Connection refused
121 passed (4 min 12 s)
- Failed: the first line of each failure, and the test's log file.
- Flaky: tests that failed and then passed when run again in the same run, as with Maven Surefire's
rerunFailingTestsCount, with the failure they had first. A test that fails every time counts once, as failed. - Skipped: disabled tests, and tests whose assumptions fail.
- Not run: tests of a class that failed before they ran, for example in
@BeforeAll; the class is listed with its failure. - Lines for outcomes that didn't happen are left out, and each list stops after 50 tests.
- It is logged at INFO when every test passed or was skipped, and at WARN otherwise, as one log event: lines of tests that are still finishing can't get into it.
- It is logged when the JUnit launcher session ends, after any reruns. Maven Surefire has one session per JVM, so
with
forkCountabove 1 there is one summary per fork. - The classic style logs none.
When a test fails
When a test fails, Pumpo logs one WARN block that says which test failed, after how long and why, and where its log is:
WARN LoggingExtension ✗ com.example.OrderTest#createOrder failed (4.2 s): expected 201 but was 500
Log: target/reports/com.example.OrderTest#createOrder/pumpo5.log
A skipped test, such as one whose assumption fails, has no block. The classic style logs none, unless detail on failure is on.
Detail only on failure
Pumpo's DEBUG lines say what each action and request was sent with, which is what explains a failure, but in a
run that passes they are mostly noise. With pn5.logging.mode.detail=onFailure, Pumpo keeps them with the test's
log instead of logging them, and prints them in the failure block of a test that fails:
INFO LoggingExtension Starting test: com.example.OrderTest#createOrder
INFO PumpoEvents (createOrder) ✓ HttpApplication › POST https://example.test/api/orders → 500 (120 ms)
WARN LoggingExtension ✗ com.example.OrderTest#createOrder failed (4.2 s): expected 201 but was 500
Log: target/reports/com.example.OrderTest#createOrder/pumpo5.log
Its lines:
11-11 09:12:03.101 DEBUG HttpApplicationSupport (createOrder) Executing command http_fetch with params {...}
11-11 09:12:03.221 INFO PumpoEvents (createOrder) ✓ HttpApplication › POST https://example.test/api/orders → 500 (120 ms)
...
- A test that passes logs only its INFO lines and above.
- The block prints the last 200 lines of the test's log, INFO lines included, so that they read in order. The log file has all of them; Pumpo writes it for every failed test.
- The block is one log event, so lines of tests running in parallel don't get mixed into it.
- DEBUG lines are kept whatever level logback sets for
dev.pumpo5. TRACE lines are kept only where logback enables TRACE. - It applies to Pumpo's own lines only. Other libraries log as logback configures them.
Logging in async threads
For direct REST Assured request/response reporting and its test context rules, see REST Assured clients.
Overview
Pumpo#5 routes log entries to a per-test log file using a ThreadLocal test ID.
Threads spawned from a test thread — via new Thread(…), an ExecutorService,
CompletableFuture, or any other async mechanism — do not inherit that value.
Their log entries end up in a shared fallback appender and are therefore not
included in the test's log file or summary output.
LogContext solves this by letting you capture the calling thread's context and
propagate it to async threads.
Quick start
import dev.pumpo5.logging.LogContext;
@Test
void myTest() throws Exception {
LogContext ctx = LogContext.capture(); // capture on the test thread
Thread t = new Thread(ctx.wrap(() -> {
LOG.info("This appears in the same test's log file");
}));
t.start();
t.join(); // must complete before the test ends
}
Important constraint
All async work must complete before the test ends.
The Pumpo#5 afterEach lifecycle hook collects and writes the log file at that
point. Any thread that is still running — or has not yet started — will have its
entries silently omitted from the file. Always call Thread.join(),
Future.get(), or an equivalent await inside the test body.
Usage patterns
Plain thread
LogContext ctx = LogContext.capture();
Thread t = new Thread(ctx.wrap(() -> {
LOG.info("Logged to the same test file");
}));
t.start();
t.join();
ExecutorService
Wrap the entire ExecutorService once; every task submitted to it will
automatically inherit the context.
LogContext ctx = LogContext.capture();
ExecutorService exec = ctx.wrap(Executors.newFixedThreadPool(4));
Future<?> f1 = exec.submit(() -> LOG.info("step 1"));
List<Future<Result>> all = exec.invokeAll(List.of(() -> step2(), () -> step3()));
f1.get();
for (Future<Result> f : all) f.get();
Plain Executor / CompletableFuture
LogContext ctx = LogContext.capture();
CompletableFuture.runAsync(ctx.wrap(() -> {
LOG.info("Async completion logged to the same test");
})).join();
Manual apply / clear
Use this when you cannot pass a lambda — for example, when configuring a third-party callback framework.
LogContext ctx = LogContext.capture();
// Pass ctx to the other thread, then inside that thread:
ctx.apply();
try {
LOG.info("Logged to the originating test's file");
} finally {
ctx.clear(); // always in a finally block
}
Method reference
LogContext::capture
public static LogContext capture()
Captures the calling thread's current test log context. Call this on the test
thread before handing work off to async code. The returned LogContext is
immutable and safe to share across threads.
LogContext::wrap(Runnable)
public Runnable wrap(Runnable runnable)
Returns a Runnable that installs this context before delegating to runnable
and clears it afterwards.
LogContext::wrap(Callable)
public <T> Callable<T> wrap(Callable<T> callable)
Returns a Callable that installs this context before delegating to callable
and clears it afterwards.
LogContext::wrap(Executor)
public Executor wrap(Executor executor)
Returns an Executor that installs this context for every submitted task.
LogContext::wrap(ExecutorService)
public ExecutorService wrap(ExecutorService executor)
Returns an ExecutorService that installs this context for every submitted task.
Lifecycle methods (shutdown, awaitTermination, etc.) are delegated directly
to the underlying executor unchanged.
LogContext::apply
public void apply()
Installs this context on the current thread. Always pair with clear() in a
finally block. Prefer the wrap(…) helpers which do this automatically.
LogContext::clear
public void clear()
Removes this context from the current thread, reverting it to the shared fallback
state. Always call in a finally block after apply().
Fallback behaviour
If LogContext.capture() is called from a thread that is not running inside a
Pumpo#5 test (e.g. a static initialiser or a background daemon), the captured
context holds the shared fallback UUID. No exception is thrown, but log entries
written through that context are effectively lost for file and summary output
modes. When pn5.logging.mode.live=true the entries still reach stdout via
logback's normal pipeline.