2018年3月14日星期三

Magento 2 日志的更多细节及数据库日志活动

Monolog

Magento 2 使用 PSR-3 标准. By default默认情况下, Magento 2 使用 Monolog. Monolog 实现Psr\Log\LoggerInterface接口,在di.xml配置文件中.

开始使用日志

要开始使用日志,您必须得到 \Psr\Logger\LoggerInterface 实例.
另一种方式如下:
class SomeModel
 {
     private $logger;

     public function __construct(\Psr\Logger\LoggerInterface $logger)
     {
         $this->logger = $logger;
     }

     public function doSomething()
     {
         try {
             //do something
         } catch (\Exception $e) {
             $this->logger->critical('Error message', ['exception' => $e]);
         }
     }
 }

数据库日志活动

示例 - 数据库日志活动

记录数据库日志,使用Magento\Framework\DB\LoggerInterface, 其中有两种实现方案:
  • Logs nothing (默认): Magento\Framework\DB\Logger\Quiet
  • 日志保存在 var/log 目录: Magento\Framework\DB\Logger\File
添加下面的块以配置基于文件的日志:

<type name="Magento\Framework\DB\Logger\File">
    <arguments>
        <argument name="logAllQueries" xsi:type="boolean">true</argument>
        <argument name="debugFile" xsi:type="string">log/db.log</argument>
    </arguments>
</type>

2 条评论:

  1. Do you need to increase your credit score?
    Do you intend to upgrade your school grade?
    Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
    Do you need any information concerning any database.
    Do you need to retrieve deleted files?
    Do you need to clear your criminal records or DMV?
    Do you want to remove any site or link from any blog?
    you should contact this hacker, he is reliable and good at the hack jobs..
    contact : cybergoldenhacker at gmail dot com

    回复删除
  2. I can’t say much but with my experience through divorce, I had no one until I met hackingsetting50@gmail.com online then I contacted him, surprisingly he helped me hack into my partner's phone and all his social media platforms and i can now access everything and even documented and printed stuffs to show as evidence , now I’m happy with my kids and working for Riches. I hope this helps anyone in need.

    Thanks.

    回复删除

注意:只有此博客的成员才能发布评论。

Also Read: