【问题标题】:monolog sending old logs独白发送旧日志
【发布时间】:2019-02-11 12:35:39
【问题描述】:

W 有 web-app,用 symfony-flex 构建。对于部署,我使用capistrano。对于记录关键日志,我以这种方式配置了独白:

monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            channels: ['!translation']
            excluded_http_codes: [{ 404: ['^/security/login'] }]
            handler: grouped
        grouped:
            type: group
            members: [deduplicated]
        deduplicated:
            type:    deduplication
            handler: swift
        swift:
            type:       swift_mailer
            from_email: '%mailer_user%'
            to_email:   ['email1@gmail.com', 'email2@gmail.com']
            subject:    "???????? %%level_name%% %%level%%"
            level:      info
            formatter:  monolog.formatter.html
            content_type: text/html

SwiftMailer 配置:

swiftmailer:
    url: '%env(MAILER_URL)%'
    spool: { type: 'memory' }

除了每次发布后的日志外,一切正常。我收到了以前发送的旧日志。示例:

也许我在配置中遗漏了什么?

【问题讨论】:

  • 这可能与 swiftmailer 的 spooler 有关。你能告诉我们 Swiftmailer 的配置吗?
  • @EmanuelOster 我使用默认的,添加到问题中。
  • 您的问题解决了吗?
  • 您是否检查过这不是发送和接收服务器双方的邮件服务器问题?当有大量请求时,邮件服务器可以对邮件进行排队,这可能是邮件事务的两端。也许你可以用简单的本地 smtp 服务器来测试这个,比如 MailDev github.com/djfarrelly/MailDev
  • 我一直在做的就是删除这一行。假脱机:{类型:'内存'}

标签: symfony capistrano monolog symfony-flex


【解决方案1】:

deduplication 处理程序类型的 MonologBu​​ndle 配置具有额外的潜在参数 - 包括

store:应该保存去重日志的文件/路径,默认为%kernel.cache_dir%/monolog_dedup_*

它正在重新读取部署之前缓存目录中的文件。

我还使用 Capistrano 部署我的网站 - 但我确实在我的网站的不同部署之间共享缓存目录。我的共享文件配置是set :linked_dirs, [fetch(:log_path)] - 仅共享日志以保持长期更新。缓存目录仍在 ./var/cache 中,但它是在每次部署时新创建的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多