1. Go to this page and download the library: Download jop-software/typo3-loki library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jop-software / typo3-loki example snippets
$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [
// Log handling configuration for ERROR logs
// Set this to DEBUG to process all logs.
\TYPO3\CMS\Core\Log\LogLevel::ERROR => [
// Convert all logs to JSON to scrape them with loki clients like Promtail
\Jops\TYPO3\Loki\Log\Writers\JsonWriter::class => [],
],
];
$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [
// Log handling configuration for ERROR logs
// Set this to DEBUG to process all logs.
\TYPO3\CMS\Core\Log\LogLevel::ERROR => [
// Configure LokiWrite to send logs to Loki
\Jops\TYPO3\Loki\Log\Writers\LokiWriter::class => [
"labels" => [
"key" => "value",
],
],
],
];