Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Email symfony2.3 spool monolog错误电子邮件输入命令_Email_Symfony_Command_Monolog - Fatal编程技术网

Email symfony2.3 spool monolog错误电子邮件输入命令

Email symfony2.3 spool monolog错误电子邮件输入命令,email,symfony,command,monolog,Email,Symfony,Command,Monolog,我知道这个问题已经在这篇文章中提过了,但答案并不能提供一个完整的解决方案,我也不能对原来的文章发表评论 我需要在命令中发送一封独白错误电子邮件。电子邮件在文件后台处理程序中正确排队;不幸的是,我被迫使用内存假脱机。 奇怪的是,为手动刷新spool而提供的代码snipper确实适用于在我的代码中生成的电子邮件,而不是独白。 有人知道为什么会发生这种情况,以及是否可以使用内存假脱机吗 config.yml: # Swiftmailer Configuration swiftmailer: t

我知道这个问题已经在这篇文章中提过了,但答案并不能提供一个完整的解决方案,我也不能对原来的文章发表评论

我需要在命令中发送一封独白错误电子邮件。电子邮件在文件后台处理程序中正确排队;不幸的是,我被迫使用内存假脱机。 奇怪的是,为手动刷新spool而提供的代码snipper确实适用于在我的代码中生成的电子邮件,而不是独白。 有人知道为什么会发生这种情况,以及是否可以使用内存假脱机吗

config.yml:

# Swiftmailer Configuration
swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    spool:     { type: memory }

# Monolog Configuration
monolog:
    channels: ["account.create"]
    handlers:
        account.create.group:
            type: group
            members: [account.create.streamed, account.create.buffered]
            channels: [account.create]
        account.create.streamed:    
            type: stream
            path: %kernel.logs_dir%/accounts_creation.log
            level: info
        account.create.buffered:
            type: buffer
            handler: account.create.swift
        account.create.swift:
            type: swift_mailer
            from_email: xxx@yyy.com
            to_email: aaa@gmail.com
            subject: 'An Error Occurred while managing zzz!'
            level: critical
monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      nested
        nested:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
            channels: [!account.create]
try
{
    //code that could block
}
catch(ManageUserBlockingExceptionInterface $e)
{
    $exitCode       = self::EXIT_CODE_ERROR_BLOCKING;

    //le eccezioni bloccanti vengono loggate e non si conferma che
    //il messaggio è stato utilizzato ma si termina la coda
    if(!\is_null($this->logger))
    {
       $this->logger->crit($e->getMessage());
    }
}
配置产品名称:

# Swiftmailer Configuration
swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    spool:     { type: memory }

# Monolog Configuration
monolog:
    channels: ["account.create"]
    handlers:
        account.create.group:
            type: group
            members: [account.create.streamed, account.create.buffered]
            channels: [account.create]
        account.create.streamed:    
            type: stream
            path: %kernel.logs_dir%/accounts_creation.log
            level: info
        account.create.buffered:
            type: buffer
            handler: account.create.swift
        account.create.swift:
            type: swift_mailer
            from_email: xxx@yyy.com
            to_email: aaa@gmail.com
            subject: 'An Error Occurred while managing zzz!'
            level: critical
monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      nested
        nested:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
            channels: [!account.create]
try
{
    //code that could block
}
catch(ManageUserBlockingExceptionInterface $e)
{
    $exitCode       = self::EXIT_CODE_ERROR_BLOCKING;

    //le eccezioni bloccanti vengono loggate e non si conferma che
    //il messaggio è stato utilizzato ma si termina la coda
    if(!\is_null($this->logger))
    {
       $this->logger->crit($e->getMessage());
    }
}
用法示例:

# Swiftmailer Configuration
swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    spool:     { type: memory }

# Monolog Configuration
monolog:
    channels: ["account.create"]
    handlers:
        account.create.group:
            type: group
            members: [account.create.streamed, account.create.buffered]
            channels: [account.create]
        account.create.streamed:    
            type: stream
            path: %kernel.logs_dir%/accounts_creation.log
            level: info
        account.create.buffered:
            type: buffer
            handler: account.create.swift
        account.create.swift:
            type: swift_mailer
            from_email: xxx@yyy.com
            to_email: aaa@gmail.com
            subject: 'An Error Occurred while managing zzz!'
            level: critical
monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      nested
        nested:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
            channels: [!account.create]
try
{
    //code that could block
}
catch(ManageUserBlockingExceptionInterface $e)
{
    $exitCode       = self::EXIT_CODE_ERROR_BLOCKING;

    //le eccezioni bloccanti vengono loggate e non si conferma che
    //il messaggio è stato utilizzato ma si termina la coda
    if(!\is_null($this->logger))
    {
       $this->logger->crit($e->getMessage());
    }
}
记录器通过依赖项注入作为服务注入到服务中:

...
<argument type="service" id="monolog.logger.account.create" on-invalid="null" />
...

服务有意发送电子邮件后立即调用;我注意到,相同的代码,放入命令并适应命令环境,即$this->container变为$this->getContainer(),可能由于范围更改而无法工作?

您是否可以发布一些命令示例代码以及如何记录错误?刚才添加的代码片段只是一个想法……您是否尝试删除
通道:[account.create]
来自您的
帐户.create.group
?我从未在我的组句柄中专门指定过频道否,频道:[account.create]必须将特定的通道日志传递给组处理程序,否则会写入任何日志消息,即使它不是通道的一部分。显然,我尝试将通道移动到组处理程序,但不起作用。有趣的是,我也使用Monolog处理错误电子邮件,使用内存假脱机,甚至不必刷新假脱机来发送它们立即。当我在控制台命令中执行了
$logger=$this->getContainer()->get('monolog.logger.mychannel');$logger->error('test');
在您的命令中尝试作为测试,看看是否有效,在记录错误的服务之外。