没有调用Symfony kernel.terminate EventListener

时间:2017-09-19 11:36:12

标签: symfony symfony-3.2

这是我的service.yml

data_generate:
    class: AppBundle\Model\EventListener
    arguments: ["@service_container"]
    tags:
        - { name: kernel.event_listener, event: kernel.terminate, method: onTerminate }

听众代码

class EventListener{
    private $container;
    private $logger;

    public function __construct(ContainerInterface $container){
         $this->container = $container;
         $this->logger = $this->container->get('logger');
    }

    public function onTerminate(PostResponseEvent $event){
         $this->logger->info("test");
    }
}

没有记录任何内容。

我还检查过听众是否已使用

注册
 php bin/console debug:event-dispatcher kernel.terminate

这是回复

------- ----------------------------------------------------------------------------------- ---------- 
  Order   Callable                                                                            Priority  
 ------- ----------------------------------------------------------------------------------- ---------- 
  #1      AppBundle\Model\EventListener::onTerminate()                        0         
  #2      Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onTerminate()   0         
  #3      Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelTerminate()    -1024     
 ------- ----------------------------------------------------------------------------------- ----------

monolog config

monolog:
    handlers:
        main:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            channels: [!event]
        console:
            type:   console
            channels: [!event, !doctrine]

我需要为kernel.terminate设置其他配置吗?

0 个答案:

没有答案