Breaking: #110219 - Log request ID provided by log processor
See forge#110219
Description
The unique ID of the current request, used to correlate all log entries
written during a single request, was previously passed as constructor
argument from
\TYPO3\ to every
\TYPO3\ instance, which in turn copied it into
each created
\TYPO3\.
The request ID is now added to log records at logging time by the new log
processor
\TYPO3\, which
Log attaches automatically to every logger it creates, for
all severity levels covered by the configured log writers. The processor
is registered internally on purpose — not via
$GLOBALS — so it cannot be removed
accidentally by overriding the global processor configuration.
The following method signatures have changed:
Logger::__no longer accepts a secondconstruct () $requestargument, the protected propertyId Logger::$requesthas been removedId Lognow expects aManager::__ construct () \TYPO3\object instead of a string, and creates one itself if omittedCMS\ Core\ Core\ Request Id - The protected method
Logno longer receives aManager:: make Logger () $requestargumentId
The generated log output is unchanged: log records written by configured
writers carry the same request ID as before, available via
Log.
Impact
Instantiating
Log with a string request ID will raise a PHP
\Type.
Passing a second argument to the
Logger
constructor is ignored.
Log records created by a manually instantiated
Logger
— bypassing
Log — no longer contain a request ID, unless the
Request is attached manually.
Affected installations
TYPO3 installations with third-party extensions instantiating
Logger
or
Log directly with a custom request ID,
which is very unlikely. Extensions obtaining loggers via dependency
injection, the
# attribute,
Logger
or
Log are not affected.
Migration
Obtain loggers through dependency injection or
Log, which attach the
Request automatically.
For manually created loggers that should add the request ID to their log records, attach the processor explicitly:
use TYPO3\CMS\Core\Core\RequestId;
use TYPO3\CMS\Core\Log\Logger;
use TYPO3\CMS\Core\Log\Processor\RequestIdProcessor;
$logger = new Logger('my.channel');
$logger->addWriter(LogLevel::WARNING, $myWriter);
$logger->addProcessor(LogLevel::WARNING, new RequestIdProcessor(new RequestId()));