我是一个Symfony的新手,所以请指出任何明显的错误:)
我有一个发送推送通知的服务。我正在尝试将日志对象传递给该服务,以便我可以写入主日志处理程序。 总之,这并没有被写入到任何地方,我不知道哪里出错了。
我从我的代码中拿掉了一些东西,但这基本上是我的想法。
blah\CoreBundle\Service\PushTask.php
public function __construct(
\Doctrine\ORM\EntityManager $entityManager,
$logger
) {
$this->entityManager = $entityManager;
$this->logger = $logger;
}
...
public function pushSomething()
{
$this->logger->addInfo('test'); // not writing
}
config_dev.yml
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: info
blah\CoreBundle\Resources\config\services.xml
<service id="civix_core.push" class="blah\CoreBundle\Service\PushTask">
<argument type="service" id="doctrine.orm.entity_manager" />
<argument type="service" id="logger" />
</service>