Deprecation: #109295 - DatabaseWriter::setLogTable()/getLogTable() 

See forge#109295

Description 

The methods setLogTable() and getLogTable() in \TYPO3\CMS\Core\Log\Writer\DatabaseWriter have been deprecated.

DatabaseWriter is a dedicated writer for the sys_log table. Its writeLog() method maps LogRecord fields to the sys_log schema ( request_id, time_micro, component, level, message, data, tstamp). Allowing an arbitrary table to be set via setLogTable() created a false sense of flexibility - any custom table needs to replicate the full sys_log schema to work correctly.

The long-term goal is to make DatabaseWriter final and to remove the $logTable property entirely.

Impact 

Calling setLogTable() or getLogTable() triggers a PHP E_USER_DEPRECATED error. This also includes passing logTable as a configuration option when DatabaseWriter is registered via $GLOBALS['TYPO3_CONF_VARS']['LOG'] , since the AbstractWriter constructor resolves options to set*() calls.

Support will be removed in TYPO3 v15.0.

Affected installations 

Installations that configure DatabaseWriter with a custom logTable option, or that call setLogTable() or getLogTable() on a DatabaseWriter instance.

The extension scanner detects direct calls to ->setLogTable() and ->getLogTable(). The more common case, passing logTable as a configuration option via $GLOBALS['TYPO3_CONF_VARS']['LOG'] , cannot be detected automatically and requires a manual search for DatabaseWriter usage with a logTable key.

Migration 

Replace DatabaseWriter with a dedicated writer that extends \TYPO3\CMS\Core\Log\Writer\AbstractWriter and implements writeLog() with explicit field mapping for the custom table.

Before:

use Psr\Log\LogLevel;
use TYPO3\CMS\Core\Log\Writer\DatabaseWriter;

$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'][LogLevel::WARNING] =
[
    DatabaseWriter::class => ['logTable' => 'my_custom_log'],
];
Copied!

After:

EXT:my_extension/Classes/Log/Writer/MyCustomTableWriter.php
namespace MyVendor\MyExtension\Log\Writer;

use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Log\LogRecord;
use TYPO3\CMS\Core\Log\Writer\AbstractWriter;
use TYPO3\CMS\Core\Log\Writer\WriterInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class MyCustomTableWriter extends AbstractWriter
{
    public function writeLog(LogRecord $record): WriterInterface
    {
        GeneralUtility::makeInstance(ConnectionPool::class)
            ->getConnectionForTable('my_custom_log')
            ->insert('my_custom_log', [
                'created' => (int)$record->getCreated(),
                'level' => $record->getLevel(),
                'message' => $record->getMessage(),
            ]);
        return $this;
    }
}
Copied!
use Psr\Log\LogLevel;
use MyVendor\MyExtension\Log\Writer\MyCustomTableWriter;

$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'][LogLevel::WARNING] = [
    MyCustomTableWriter::class => [],
];
Copied!