Issue Feature Under Review

#111627Capture log records for a scoped part of a request

Benni Mack 11/26/26, 17:25 updated 11/26/26, 19:15

Description

Code that wants to inspect the log records of the current request (debugging tools such as the admin panel, tests, diagnostics) currently has to register an own log writer in $GLOBALS[‘TYPO3_CONF_VARS’][‘LOG’] and keep the collected records in a shared service.

This has several drawbacks:
  • The writer has to be registered globally at DEBUG level, so every logger creates and processes debug records in every request, even when nobody reads them.
  • Loggers that were already created keep their writers, so changing the configuration at runtime does not reach them.
  • The collected records live in a shared service, which keeps them across requests in long-running processes (e.g. FrankenPHP worker mode) and leaks records of one request into the next.

EXT:adminpanel does exactly this with its InMemoryLogWriter.

Proposal: LogManager offers a capture scope, e.g.

$capture = $logManager->startCapture(LogLevel::DEBUG);
try {
$response = $handler->handle($request);
} finally {
$capture->stop();
}
$records = $capture->getRecords();

While a capture is active, all loggers (including already created ones) pass records of the requested level to it, independent of the configured writers. Without an active capture the overhead is a single level comparison.

The admin panel switches to this API and drops the globally registered InMemoryLogWriter.

Reviews 1

History 02

  1. Gerrit Code Review pushed patch set 1 for main to change 98081 status New Under Review 11/26/26, 19:13

  2. Gerrit Code Review pushed patch set 2 for main to change 98081 11/26/26, 19:15