本文介绍了Symfony2 Monolog to Email Errors 为什么 swiftmailer.transport.real 是不存在的服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将 symfony 从 2.3 更新到 2.4 后,我得到 ServiceNotFoundException

after updating symfony from 2.3 to 2.4 i got ServiceNotFoundException

 Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException' with message 'The service "monolog.handler.mojhandler" has a dependency on a non-existent service "swiftmailer.transport.real".' in E:\wamp\www\project\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass.php on line 59

这是我的 config_prod.yml

here is my config_prod.yml

imports:
    - { resource: config.yml }
monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      streamed
        streamed:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        mail:
            type:         fingers_crossed
            action_level: error
            handler:      buffered
            channels: ["!app"] # Dont log app because we dont' want 404 errors sending
        buffered:
            type:    buffer
            handler: mojhandler
        mojhandler:
            type:       swift_mailer
            from_email: %mojhandler_logger_email%
            to_email:   %mojhandler_logger_email%
            subject:    "[Panel] An Error Occurred!"
            level:      debug

这是我在 config.yml 中的 swiftmailer 配置

and here is my swiftmailer configuration from config.yml

# Swiftmailer Configuration
swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    port:      %mailer_port%
    auth_mode: %mailer_auth_mode%
    encryption: %mailer_encryption%

我该如何解决?

推荐答案

如果您没有在 swiftmailer 配置下设置 'spool' 配置值,则升级到 Monolog Bundle 2.5.0 时似乎是一个错误.

It appears to be an error when upgrading to Monolog Bundle 2.5.0 that causes this if you do not have the 'spool' config value set under the swiftmailer configuration.

这篇关于Symfony2 Monolog to Email Errors 为什么 swiftmailer.transport.real 是不存在的服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 18:13