我想调试后端,需要写一些日志。我尝试了下面的代码,但它不工作,它没有写任何东西!你能帮我吗?
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.');
}发布于 2017-01-20 19:26:55
尝试使用PHP,调整扩展键并选择error-level
// 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模块中找到带有时间戳和更多信息的消息。
发布于 2018-10-01 17:34:45
默认情况下,不记录LogLevel信息。(TYPO3 V8)您必须为自己定义记录器或将常规LogLevel设置为INFO:
在LocalConfiguration.php中将常规LogLevel设置为INFO:
'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中
$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
发布于 2017-01-21 05:09:32
您使用的代码不会记录到后端日志模块,但(默认情况下)会记录到文件typo3temp/logs/typo3.log或typo3temp/var/logs/typo3_*.log。
它是new logging framework的一部分。
https://stackoverflow.com/questions/41762141
复制相似问题