dongzhuo5185 2017-01-20 11:04
浏览 68
已采纳

如何在TYPO3后端写入登录?

I would like to debug backend and need to write some logs. I tried the code belowed but it is not working, it doesn't write anything ! Can you help me ?

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.');
    }
  • 写回答

3条回答 默认 最新

  • dsyrdwdbo47282676 2017-01-20 11:26
    关注

    Try following PHP, adapt your extension-key and choose 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);
    

    Then you will find your message with timestamp and further informations in sys_log table or in BE modul with name 'Log'.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥21 matlab怎么求时域信号的二阶导数
  • ¥15 判断两个表是否完全相同
  • ¥15 java map类型数据格式,如何快速通过前缀匹配元素
  • ¥15 stc12c5a60s2、QMC5883L、LCD1602组合测量磁场所需程序
  • ¥15 vba参数转c++ SAFEARRAY
  • ¥20 Win11测试yolov4,“找不到nvcuda.dll”怎么办?
  • ¥15 simulink绘制bode图
  • ¥15 php_network_getaddresses: getaddrinfo failed: Name or service not known
  • ¥15 用msg发消息出现的问题
  • ¥15 unity3d机械臂