首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在TYPO3后台写日志?

如何在TYPO3后台写日志?
EN

Stack Overflow用户
提问于 2017-01-20 19:04:30
回答 3查看 3.7K关注 0票数 3

我想调试后端,需要写一些日志。我尝试了下面的代码,但它不工作,它没有写任何东西!你能帮我吗?

代码语言:javascript
复制
var $logger;

    public function __construct()
    {
        parent::__construct();
        // desactiver le cache sinoin les FE plugins ne sont pas réactualisé
        // desactivation dans le backend modifie des liens en ajoutant '/no_cache/' devant le lien
        // les liens deviennent inutilisables
        $GLOBALS['TSFE']->set_no_cache();
        $this->logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__);
        $this->logger->info('Everything went fine.');
    }
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-01-20 19:26:55

尝试使用PHP,调整扩展键并选择error-level

代码语言:javascript
复制
// Log message
$logMessage = 'Everything went fine.';
// Option extension key / module name
$extKey = 'my_extension';
// Error-level: 0 = message, 1 = error (user problem), 2 = System Error (which should not happen), 3 = security notice (admin)
$errorLevel = 0;
// Write sys_log using \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog
$GLOBALS['BE_USER']->simplelog($logMessage, $extKey, $errorLevel);

然后,您将在sys_log表或名为'Log‘的BE模块中找到带有时间戳和更多信息的消息。

票数 4
EN

Stack Overflow用户

发布于 2018-10-01 17:34:45

默认情况下,不记录LogLevel信息。(TYPO3 V8)您必须为自己定义记录器或将常规LogLevel设置为INFO:

在LocalConfiguration.php中将常规LogLevel设置为INFO:

代码语言:javascript
复制
'LOG' => [
    'writerConfiguration' => [
        \TYPO3\CMS\Core\Log\LogLevel::INFO => [
            'TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => [
                'logFile'  => 'typo3temp/var/logs/yourlog_info.log',
            ],
        ],
    ],
],

或者在我的命名空间Taywa\Artcollection\Command\ImportCommandController的ext_localconfig.php中

代码语言:javascript
复制
$GLOBALS['TYPO3_CONF_VARS']['LOG']['Taywa']['Artcollection']['Command']['ImportCommandController']['writerConfiguration']
= array(
            \TYPO3\CMS\Core\Log\LogLevel::INFO => [
                'TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => [
                    'logFile'  => 'typo3temp/var/logs/typo3_artcollection.log',
                ],
            ],
        );

关于这一点的一些文档:

https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Logging/Configuration/Index.html

票数 2
EN

Stack Overflow用户

发布于 2017-01-21 05:09:32

您使用的代码不会记录到后端日志模块,但(默认情况下)会记录到文件typo3temp/logs/typo3.logtypo3temp/var/logs/typo3_*.log

它是new logging framework的一部分。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41762141

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档